MiddleKit.Core.Model | index /usr/local/share/webware/MiddleKit/Core/Model.py

Modules

``

os | sys |  |

Classes

``

MiscUtils.Configurable.Configurable
  Model
exceptions.Exception(exceptions.BaseException)
  ModelError

class Model(MiscUtils.Configurable.Configurable)
`` | `A Model defines the classes, attributes and enumerations of an application. It also provides access to the Python classes that implement these structures for use by other MiddleKit entities including code generators and object stores.`

Methods defined here:

__getstate__(self)

__init__(self, filename=None, classesFilename=None, configFilename=None, customCoreClasses={}, rootModel=None, havePythonClasses=1)

allKlassesByName(self)
  `Get klasses by name.
  Returns a dictionary of all the klasses in this model, unique
  by name, including klasses inherited from parent models.`

allKlassesInDependencyOrder(self)
  `Get klasses in dependency order.
  Returns a sequence of all the klasses in this model, in an
  order such that klasses follow the klasses they refer to
  (via obj ref attributes).
  The typical use for such an order is to avoid SQL errors
  about foreign keys referring to tables that do not exist.
  A ModelError is raised if there is a dependency cycle
  since there can be no definitive order when a cycle exists.
  You can break cycles by setting Ref=False for some
  attribute in the cycle.`

allKlassesInOrder(self)
  `Get klasses in order.
  Returns a sequence of all the klasses in this model, unique by
  name, including klasses inherited from parent models.
  The order is the order of declaration, top-down.`

allModelsDepthFirstLeftRight(self, parents=None)
  `Return ordered list of models.
  Returns a list of all models, including self, parents and
  ancestors, in a depth-first, left-to-right order. Does not
  remove duplicates (found in inheritance diamonds).
  Mostly useful for readParents() to establish the lookup
  order regarding model inheritance.`

awakeFromRead(self)

configFilename(self)

coreClass(self, className)
  `Return code class.
  For the given name, returns a class from MiddleKit.Core
  or the custom set of classes that were passed in via initialization.`

coreClassNames(self)
  `Return a list of model class names found in MiddleKit.Core.`

defaultConfig(self)

dontReadParents(self)
  `Set attributes _parents and _searchOrder.
  Used internally for the rare case of reading class files directly
  (instead of from a model directory).`

filename(self)

klass(self, name, default=<class MiscUtils.NoDefault at 0x832da1c>)
  `Get klass.
  Returns the klass with the given name, searching the parent
  models if necessary.`

klasses(self)
  `Get klasses.
  Returns an instance that inherits from Klasses, using the base
  classes passed to __init__, if any.
  See also: klass(), allKlassesInOrder(), allKlassesByName()`

name(self)

printWarnings(self, out=None)

pyClassForName(self, name)
  `Get Python class for name.
  Returns the Python class for the given name, which must be present
  in the object model. Accounts for setting('Package').
  If you already have a reference to the model klass, then you can
  just ask it for klass.pyClass().`

read(self, filename, isClassesFile=0)

readKlassesDirectly(self, path)

readKlassesInModelDir(self)
  `Read the Classes.csv or Classes.pickle.cache file as appropriate.`

readParents(self, parentFilenames=None)
  `Reads the parent models of the current model, as
  specified in the 'Inherit' setting.
  The attributes _parents and _searchOrder are set.`

setName(self, name)

usesExternalSQLEnums(self)

Data and other attributes defined here:

pickleVersion = 1

Methods inherited from MiscUtils.Configurable.Configurable:

commandLineConfig(self)
  `Return the settings that came from the command-line.
  These settings come via addCommandLineSetting().`

config(self)
  `Return the configuration of the object as a dictionary.
  This is a combination of defaultConfig() and userConfig().
  This method caches the config.`

configName(self)
  `Return the name of the configuration file without the extension.
  This is the portion of the config file name before the '.config'.
  This is used on the command-line.`

configReplacementValues(self)
  `Return a dictionary for substitutions in the config file.
  This must be a dictionary suitable for use with "string % dict"
  that should be used on the text in the config file.
  If an empty dictionary (or None) is returned, then no substitution
  will be attempted.`

hasSetting(self, name)
  `Check whether a configuration setting has been changed.`

printConfig(self, dest=None)
  `Print the configuration to the given destination.
  The default destionation is stdout. A fixed with font is assumed
  for aligning the values to start at the same column.`

setSetting(self, name, value)
  `Set a particular configuration setting.`

setting(self, name, default=<class MiscUtils.NoDefault at 0x832da1c>)
  `Return the value of a particular setting in the configuration.`

userConfig(self)
  `Return the user config overrides.
  These settings can be found in the optional config file.
  Returns {} if there is no such file.
  The config filename is taken from configFilename().`

class ModelError(exceptions.Exception)

``

Method resolution order:
  ModelError
  exceptions.Exception
  exceptions.BaseException
  __builtin__.object

Methods defined here:

__init__(self, error, line=None)

printError(self, filename)

setLine(self, line)

Data descriptors defined here:

__weakref__
  `list of weak references to the object (if defined)`

Data and other attributes inherited from exceptions.Exception:

__new__ = <built-in method __new__ of type object at 0x8118b60>
  `T.__new__(S, ...) -> a new object with type S, a subtype of T`

Methods inherited from exceptions.BaseException:

__delattr__(...)
  `x.__delattr__('name') <==> del x.name`

__getattribute__(...)
  `x.__getattribute__('name') <==> x.name`

__getitem__(...)
  `x.__getitem__(y) <==> x[y]`

__getslice__(...)
  `x.__getslice__(i, j) <==> x[i:j]
  Use of negative indices is not supported.`

__reduce__(...)

__repr__(...)
  `x.__repr__() <==> repr(x)`

__setattr__(...)
  `x.__setattr__('name', value) <==> x.name = value`

__setstate__(...)

__str__(...)
  `x.__str__() <==> str(x)`

Data descriptors inherited from exceptions.BaseException:

__dict__

args

message
  `exception message`

Functions

``

dump(...)
  `dump(obj, file, protocol=0) -- Write an object in pickle format to the given file.
  See the Pickler docstring for the meaning of optional argument proto.`

load(...)
  `load(file) -- Load a pickle from the given file`