[Schevo-devel] multiple sources for schemata
Matthew Scott
mscott at goldenspud.com
Tue Dec 27 15:13:24 EST 2005
Here's a snippet of code that I am hoping to refine over time.
The software I'm writing for in-house use is going to incorporate
several aspects of our business into one database.
However, I need to be able to separate the schema into discrete
portions (some of which may be dependent on others), so that they can
be tailored to other uses.
So, currently I am including schema files within schema_001.py -- this
is a little tricky at the moment since it needs to include the source
for each one, since none of them will have been imported already using
a proper schema preamble.
What I'd like to see eventually is a way to specify other schemata to
be imported using a simple syntax within a schema_###.py file. For
instance, the code below this message might be reduced to:
from schevo.schema import *
schevo.schema.prep(locals())
use('schevo.icon.schema') # Not giving version implies latest.
use('schevo.identity.schema')
use('sphyra.schema.crm', 1)
use('sphyra.schema.inventory', 1)
use('sphyra.schema.sequence', 1)
We could segue into discussions about multiple databases and
inter-database entity references, but we'll get deep into that in a
few months :)
Finally, here is the code I am using at the moment:
# All Schevo schema modules must have these lines.
from schevo.schema import *
schevo.schema.prep(locals())
exec(schevo.icon.schema.preamble)
exec(schevo.identity.schema.preamble)
# Can we use eggs for this?
import os
import sphyra.schema
schema_path = os.path.dirname(sphyra.schema.__file__)
def src(module_name):
return file(os.path.join(schema_path, '%s.py' % module_name), 'U').read()
exec(src('crm_001'))
exec(src('inventory_001'))
exec(src('sequence_001'))
class System(E.Entity):
"""General information and default profiles."""
_plural = 'System'
default_company = f.entity('Company')
default_markup_profile = f.entity('MarkupProfile')
default_tax_profile = f.entity('TaxProfile')
_hide('t_create', 't_delete')
_initial = [
((u'Acme, Inc.', ),
(u'Standard', ),
(u'Local', ),
),
]
_initial_priority = 99
@classmethod
def x_get(cls):
"""Returns the singleton entity."""
return cls._extent[1]
--
Matthew R. Scott
More information about the Schevo-devel
mailing list