Package application :: Module schema
[hide private]
[frames] | no frames]

Module schema

source code

Classes [hide private]
  TypeReference
Reference a core schema type (e.g.
  ActiveDescriptor
Abstract base for descriptors needing activation by their classes
  Activator
Metaclass that activates contained ``ActiveDescriptor`` instances
  Descriptor
Descriptor for a schema-defined attribute
  One
  Many
  Sequence
  Mapping
  Calculated
  Endpoint
Represent an endpoint
  AttributeAsEndpoint
Adapt a Descriptor or attribute name to use as an Endpoint factory
  Cloud
Represent a cloud as a set of endpoints grouped by policy
  __setup__
List subclass that makes a better error message when you try to call __setup__ directly.
  ItemClass
Metaclass for schema.Item
  CollectionClass
The metaclass to use for declaring collection classes
  ItemRoot
Schema template for a named root
  Item
Base class for schema-defined Kinds
  AnnotationItem
Persistent data for Annotation types
  Comparator
  AnnotationClass
Metaclass for annotation types
  Annotation
Base class for annotations
  TypeClass
Metaclass for type types
  StructClass
Metaclass for struct types
  SchemaStruct
  Struct
  SchemaEnumValue
  EnumerationClass
Metaclass for enumerations
  Enumeration
Base class for defining enumerations
  ns
Shortcut namespace for referring to classes and instances in a parcel
  ModuleMaker
Functions [hide private]
 
_is_schema(ob) source code
 
_target_type(ob) source code
 
_initializers_for(cls, skip=()) source code
 
_update_info(name, attr, data, frame=<Locale: en_US>, depth=2) source code
 
kindInfo(**attrs)
Declare metadata for a class' schema item
source code
 
initialValues(**values)
Declare computed initial values for a class' attributes
source code
 
addClouds(**clouds)
Declare clouds for a class' Kind
source code
 
observer(*attrs)
Decorator to create an observer method for `attrs`
source code
 
importString(name, globalDict={'Globals': <module 'application.Globals' from '/home/builder/...)
Import an item specified by a string
source code
 
getCaller(frame=<Locale: en_US>, level=2) source code
 
_refMap(ob) source code
 
fwdRef(parent, name, cls=<class 'application.schema.Item'>, callerInfo=<Locale: en_US>)
Get child `name` of `parent`, creating a new kindless item if needed
source code
 
resolveRef(parent, name)
Mark the forward reference to (parent,name) resolved
source code
 
assertResolved(view)
Assert that all forward references in `view` have been resolved
source code
 
parcel_name(moduleName)
Get a module's __parcel__ or __name__
source code
 
parcel_for_module(moduleName, view)
Return the Parcel for the named module
source code
 
synchronize(repoView, moduleName)
Ensure that the named module's schema is incorporated into `repoView`
source code
 
itemFor(obj, view)
Return the schema Item corresponding to ``obj`` in the given view
source code
 
initRepository(rv, packdir='/home/builder/docs/svn/chandler/repository/packs')
Ensure repository view `rv` has been initialized with core schema
source code
 
declareTemplate(item)
Declare that `item` is a template, and should be copied when it is imported into another repository view.
source code
Variables [hide private]
  all_aspects = ('required', 'indexed', 'notify', 'cardinality',...
  policy_values = ('byRef', 'byValue', 'byCloud', 'byRef', 'none...
  default_schema = {<class 'repository.schema.Kind.Kind'>: ('des...
  core_types = ['Boolean', 'Symbol', 'Importable', 'Bytes', 'Tex...
  Anything = TypeReference('//Schema/Core/Anything')
  Boolean = TypeReference('//Schema/Core/Boolean')
  Bytes = TypeReference('//Schema/Core/Bytes')
  Class = TypeReference('//Schema/Core/Class')
  Complex = TypeReference('//Schema/Core/Complex')
  Date = TypeReference('//Schema/Core/Date')
  DateTime = TypeReference('//Schema/Core/DateTime')
  DateTimeTZ = TypeReference('//Schema/Core/DateTimeTZ')
  Decimal = TypeReference('//Schema/Core/Decimal')
  Dictionary = TypeReference('//Schema/Core/Dictionary')
  Float = TypeReference('//Schema/Core/Float')
  Importable = TypeReference('//Schema/Core/Importable')
  Integer = TypeReference('//Schema/Core/Integer')
  ItemRef = TypeReference('//Schema/Core/ItemRef')
  List = TypeReference('//Schema/Core/List')
  Lob = TypeReference('//Schema/Core/Lob')
  Long = TypeReference('//Schema/Core/Long')
  NilValue = TypeReference('//Schema/Core/NilValue')
  Path = TypeReference('//Schema/Core/Path')
  Set = TypeReference('//Schema/Core/Set')
  Symbol = TypeReference('//Schema/Core/Symbol')
  Text = TypeReference('//Schema/Core/Text')
  Time = TypeReference('//Schema/Core/Time')
  TimeDelta = TypeReference('//Schema/Core/TimeDelta')
  TimeZone = TypeReference('//Schema/Core/TimeZone')
  Tuple = TypeReference('//Schema/Core/Tuple')
  URL = TypeReference('//Schema/Core/URL')
  UUID = TypeReference('//Schema/Core/UUID')
  __warningregistry__ = {('Not importing directory \'/home/build...
  name = 'NilValue'
Function Details [hide private]

kindInfo(**attrs)

source code 

Declare metadata for a class' schema item

The attributes defined by the keyword arguments will be set on the enclosing class' schema Item. For example, the following class' repository Kind will have a ``displayAttribute`` of ``"someAttr"``:
   class SomeItem(schema.Item):
       schema.kindInfo(
           displayAttribute = "someAttr",
       )

``kindInfo()`` can only be used in the body of a class that derives from ``schema.Item`` or ``schema.Enumeration``, and it will only accept keywords that are valid attributes of the ``Kind`` or ``Enumeration`` kinds, respectively.

(Note: if your class includes a ``__metaclass__`` definition, any calls to ``kindInfo`` must come *after* the ``__metaclass__`` assignment.)

initialValues(**values)

source code 

Declare computed initial values for a class' attributes

Takes keyword arguments whose names are the attribute names, and whose values are 1-argument callables taking an item and returning the value the attribute should have. For example:
   class anItem(OtherItem):
       timestamp = schema.One(schema.DateTime)

       schema.initialValues(
           timestamp = lambda self: datetime.now(),
       )

addClouds(**clouds)

source code 

Declare clouds for a class' Kind

Takes keyword arguments whose names define the clouds' aliases, and whose values are the ``schema.Cloud`` instances. For example:
   class anItem(OtherItem):
       foo = schema.One(schema.Text)
       bar = schema.Sequence(Something)

       schema.addClouds(
           sharing = schema.Cloud(foo, "displayName"),
           copying = schema.Cloud(byCloud = [bar]),
       )

importString(name, globalDict={'Globals': <module 'application.Globals' from '/home/builder/...)

source code 

Import an item specified by a string

Example Usage:
   attribute1 = importString('some.module:attribute1')
   attribute2 = importString('other.module:nested.attribute2')

'importString' imports an object from a module, according to an import specification string: a dot-delimited path to an object in the Python package namespace. For example, the string '"some.module.attribute"' is equivalent to the result of 'from some.module import attribute'.

For readability of import strings, it's sometimes helpful to use a ':' to separate a module name from items it contains. It's optional, though, as 'importString' will convert the ':' to a '.' internally anyway.

This routine was copied from PEAK's ``peak.util.imports`` module.

fwdRef(parent, name, cls=<class 'application.schema.Item'>, callerInfo=<Locale: en_US>)

source code 

Get child `name` of `parent`, creating a new kindless item if needed

If the item didn't exist or is a forward reference, the caller is logged as the source of the forward reference so that ``assertResolved()`` can identify the source of the broken reference if it remains unresolved. Forward references can be marked resolved using ``resolveRef()``.

resolveRef(parent, name)

source code 

Mark the forward reference to (parent,name) resolved

Normally, this is called by the ItemClass.update() method.

assertResolved(view)

source code 

Assert that all forward references in `view` have been resolved

If any forward references have not been resolved, raise an error listing them.

parcel_for_module(moduleName, view)

source code 

Return the Parcel for the named module

If the named module has a ``__parcel__`` attribute, its value will be used to redirect to another parcel. If the module does not have a ``__parcel__``, then a new parcel will be created, cached, and returned.

This routine is thread-safe and re-entrant.

Variables Details [hide private]

all_aspects

Value:
('required',
 'indexed',
 'notify',
 'cardinality',
 'defaultValue',
 'initialValue',
 'inheritFrom',
 'otherName',
...

policy_values

Value:
('byRef',
 'byValue',
 'byCloud',
 'byRef',
 'none',
 'byMethod',
 'literal')

default_schema

Value:
{<class 'repository.schema.Kind.Kind'>: ('description', 'notify'),
 <class 'repository.item.Item.Item'>: ('description')}

core_types

Value:
['Boolean',
 'Symbol',
 'Importable',
 'Bytes',
 'Text',
 'Integer',
 'Long',
 'Float',
...

__warningregistry__

Value:
{('Not importing directory \'/home/builder/docs/svn/chandler/samples\'\
: missing __init__.py',
  <type 'exceptions.ImportWarning'>,
  1283): 1}