| foundation.org |
riptor object %r cannot be modified after use" % self
</span><span class="cx"> )
self._setattr(attr, value)
</span><span class="lines">@@ -261,7 +261,7 @@
</span><span class="cx">
def __repr__(self):
if self.name and self.owner:
</span><span class="rem">- return "<Role %s of %s>" % (self.name,self.owner)
</span><span class="add">+ return "<Descriptor %s of %s>" % (self.name,self.owner)
</span><span class="cx"> return object.__repr__(self)
def __setDoc(self,val):
</span><span class="lines">@@ -357,19 +357,19 @@
</span><span class="cx"> itemFor(self.inverse, view)
</span><span class="rem">-class One(Role):
</span><span class="add">+class One(Descriptor):
</span><span class="cx"> cardinality = 'single'
</span><span class="rem">-class Many(Role):
</span><span class="add">+class Many(Descriptor):
</span><span class="cx"> cardinality = 'set'
</span><span class="rem">-class Sequence(Role):
</span><span class="add">+class Sequence(Descriptor):
</span><span class="cx"> cardinality = 'list'
</span><span class="rem">-class Mapping(Role):
</span><span class="add">+class Mapping(Descriptor):
</span><span class="cx"> cardinality = 'dict'
</span><span class="lines">@@ -411,7 +411,7 @@
</span><span class="cx">
class AttributeAsEndpoint(Endpoint):
</span><span class="rem">- """Adapt a Role or attribute name to use as an Endpoint factory"""
</span><span class="add">+ """Adapt a Descriptor or attribute name to use as an Endpoint factory"""
</span><span class="cx">
def __new__(cls, attr, policy):
if isinstance(attr, Endpoint):
</span><span class="lines">@@ -423,7 +423,7 @@
</span><span class="cx"> def __init__(self, attr, policy):
if isinstance(attr,str):
super(AttributeAsEndpoint,self).__init__(attr,(attr,), policy)
</span><span class="rem">- elif isinstance(attr,Role):
</span><span class="add">+ elif isinstance(attr,Descriptor):
</span><span class="cx"> self.attr = attr
super(AttributeAsEndpoint,self).__init__(None,(),policy)
else:
</span><span class="lines">@@ -525,7 +525,7 @@
</span><span class="cx"> kind.classes = {'python': cls }
kind.attributes = []
for name,attr in cls.__dict__.items():
</span><span class="rem">- if isinstance(attr,Role):
</span><span class="add">+ if isinstance(attr,Descriptor):
</span><span class="cx"> ai = itemFor(attr, view)
if ai not in kind.attributes:
kind.attributes.append(ai,name)
</span><span class="lines">@@ -689,7 +689,7 @@
</span><span class="cx">
def __init__(cls,name,bases,cdict):
for name,ob in cdict.items():
</span><span class="rem">- if isinstance(ob,Role):
</span><span class="add">+ if isinstance(ob,Descriptor):
</span><span class="cx"> basename = "%s.%s." % (parcel_name(cls.__module__), cls.__name__)
ob.annotates = _target_type(cls),
ob.activateInClass(cls,basename+name)
</span><span class="lines">@@ -1182,7 +1182,7 @@
</span><span class="cx">
def _create_schema_item(self,view):
# Create a temporary item without a kind, so as not to
</span><span class="rem">- # incur unintended
</span><span class="add">+ # incur unintended circularities.
</span><span class="cx"> return Base("tmp_parcel_for-"+self.moduleName, view, None)
def _init_schema_item(self,item,view):
</span></pre></div>
<a id="trunkchandlerapplicationschema_apitxt"></a>
<div class="modfile"><h4>Modified: trunk/chandler/application/schema_api.txt (8756 => 8757)</h4>
<pre class="diff">
<span class="info">--- trunk/chandler/application/schema_api.txt 2005-12-19 18:28:47 UTC (rev 8756)
+++ trunk/chandler/application/schema_api.txt 2005-12-19 18:59:29 UTC (rev 8757)
</span><span class="lines">@@ -8,36 +8,15 @@
</span><span class="cx"> >>> from repository.persistence.RepositoryView import NullRepositoryView
</span><span class="rem">-------------
-Introduction
-------------
</span><span class="add">+------------------
+Descriptor Objects
+------------------
</span><span class="cx">
</span><span class="rem">-TODO
</span><span class="add">+The ``Descriptor`` Base Type
+=============================
</span><span class="cx">
</span><span class="rem">-------------
-Role Objects
-------------
-
-The ``One``, ``Many``, ``Sequence``, and ``Mapping`` classes are all used to
-define roles. They are all essentially identical except for their
-``cardinality`` attribute, which controls how the repository will store the
-attribute's value::
-
- >>> schema.One.cardinality
- 'single'
- >>> schema.Many.cardinality
- 'set'
- >>> schema.Sequence.cardinality
- 'list'
- >>> schema.Mapping.cardinality
- 'dict'
-
-
-The ``Role`` Base Type
-======================
-
-The base class for roles is ``schema.Role``. It provides most of the
-default behavior of roles, so rather than duplicate examples for each
</span><span class="add">+The base class for roles is ``schema.Descriptor``. It provides most of the
+default behavior of descriptors, so rather than duplicate examples for each
</span><span class="cx"> individual role type, we'll examine the default behaviors here.
All role objects have at least the following attributes and methods:
</span><span class="lines">@@ -47,39 +26,40 @@
</span><span class="cx"> relationship, or ``None`` if the role has not been registered with a
class yet::
</span><span class="rem">- >>> role = schema.Role()
</span><span class="add">+ >>> role = schema.Descriptor()
</span><span class="cx"> >>> print role.name
None
>>> class anEntity(schema.Item):
</span><span class="rem">- ... aRole = role
</span><span class="add">+ ... aDescriptor = role
</span><span class="cx"> >>> role.name
</span><span class="rem">- 'aRole'
</span><span class="add">+ 'aDescriptor'
</span><span class="cx">
``owner`` (read-only)
The entity or relationship class in which the role was defined, or ``None``
if the role has not been registered with a class yet::
</span><span class="rem">- >>> role = schema.Role()
</span><span class="add">+ >>> role = schema.Descriptor()
</span><span class="cx"> >>> print role.owner
None
>>> class anEntity(schema.Item):
</span><span class="rem">- ... aRole = role
</span><span class="add">+ ... aDescriptor = role
</span><span class="cx"> >>> role.owner
<class '...anEntity'>
</span><span class="rem">- If a role's owner is an ``Item`` class, then setting ``aRole.inverse`` will
- invoke ``aRole.inverse.addType(aRole.owner)``, so that the inverse role
- will accept instances of the first role's owning type. This allows you
</span><span class="add">+ If a role's owner is an ``Item`` class, then setting
+ ``aDescriptor.inverse`` will invoke
+ ``aDescriptor.inverse.addType(aDescriptor.owner)``, so that the inverse
+ role will accept instances of the first role's owning type. This allows you
</span><span class="cx"> to easily define bidirectional links without "forward references"; just
leave off the `type` argument in both role definitions, and specify an
`inverse` argument for the second::
>>> class anotherEntity(schema.Item):
</span><span class="rem">- ... otherRole = schema.Role(inverse=anEntity.aRole)
- >>> anotherEntity.otherRole.type
</span><span class="add">+ ... otherDescriptor=schema.Descriptor(inverse=anEntity.aDescriptor)
+ >>> anotherEntity.otherDescriptor.type
</span><span class="cx"> <class '...anEntity'>
</span><span class="rem">- >>> anEntity.aRole.type
</span><span class="add">+ >>> anEntity.aDescriptor.type
</span><span class="cx"> <class '...anotherEntity'>
As you can see, this ensures that both roles can accept the owning type of
</span><span class="lines">@@ -115,17 +95,17 @@
</span><span class="cx"> | ...
| Data and other attributes defined here:
|
</span><span class="rem">- | name = <Role name of <class '...Kind'>>
</span><span class="add">+ | name = <Descriptor name of <class '...Kind'>>
</span><span class="cx"> | Kind Name -- One(Text)
|
| This kind's name
|
</span><span class="rem">- | subkinds = <Role subkinds of <class '...Kind'>>
</span><span class="add">+ | subkinds = <Descriptor subkinds of <class '...Kind'>>
</span><span class="cx"> | Many(Kind)
|
| Sub-kinds of this kind
|
</span><span class="rem">- | superkinds = <Role superkinds of <class '...Kind'>>
</span><span class="add">+ | superkinds = <Descriptor superkinds of <class '...Kind...
</span><span class="cx"> | Many(Kind)
|
| Super-kinds of this kind
</span><span class="lines">@@ -139,7 +119,7 @@
</span><span class="cx">
The ``doc`` and ``description`` are always strings, even if empty::
</span><span class="rem">- >>> schema.Role().description
</span><span class="add">+ >>> schema.Descriptor().description
</span><span class="cx"> ''
``inverse``
</span><span class="lines">@@ -152,10 +132,10 @@
</span><span class="cx"> ``inverse`` can be set via keyword argument to the role class'
constructor::
</span><span class="rem">- >>> role1 = schema.Role()
</span><span class="add">+ >>> role1 = schema.Descriptor()
</span><span class="cx"> >>> print role1.inverse
None
</span><span class="rem">- >>> role2 = schema.Role(inverse=role1)
</span><span class="add">+ >>> role2 = schema.Descriptor(inverse=role1)
</span><span class="cx"> >>> role2.inverse is role1
True
>>> role1.inverse is role2
</span><span class="lines">@@ -163,8 +143,8 @@
</span><span class="cx">
Or by setting the ``inverse`` attribute after construction::
</span><span class="rem">- >>> role1 = schema.Role()
- >>> role2 = schema.Role()
</span><span class="add">+ >>> role1 = schema.Descriptor()
+ >>> role2 = schema.Descriptor()
</span><span class="cx"> >>> role2.inverse = role1
>>> role2.inverse is role1
True
</span><span class="lines">@@ -173,23 +153,23 @@
</span><span class="cx">
Once set, it cannot be changed, unless it is to the same role::
</span><span class="rem">- >>> role2.inverse = schema.Role()
</span><span class="add">+ >>> role2.inverse = schema.Descriptor()
</span><span class="cx"> Traceback (most recent call last):
...
</span><span class="rem">- TypeError: Role objects are immutable; can't change 'inverse' ... once set
</span><span class="add">+ TypeError: Descriptor objects are immutable; can't change 'inverse' ...
</span><span class="cx">
>>> role2.inverse is role1 # no change took place
True
And trying to insert a new role into an existing pair also fails::
</span><span class="rem">- >>> role3 = schema.Role()
</span><span class="add">+ >>> role3 = schema.Descriptor()
</span><span class="cx"> >>> print role3.inverse
None
>>> role3.inverse = role2
Traceback (most recent call last):
...
</span><span class="rem">- TypeError: Role objects are immutable; can't change 'inverse' ... once set
</span><span class="add">+ TypeError: Descriptor objects are immutable; can't change 'inverse' ...
</span><span class="cx">
>>> print role3.inverse # no change took place
None
</span><span class="lines">@@ -210,7 +190,7 @@
</span><span class="cx"> <class '...Folder'>
>>> File.folder.inverse
</span><span class="rem">- <Role contents of <class '...Folder'>>
</span><span class="add">+ <Descriptor contents of <class '...Folder'>>
</span><span class="cx">
``type``
The ``type`` of a role can be either a ``schema.Item`` subclass, a
</span><span class="lines">@@ -224,17 +204,17 @@
</span><span class="cx">
>>> myType = schema.TypeReference('//Schema/Core/DateTime')
</span><span class="rem">- >>> print schema.Role(myType).__doc__
- Role(DateTime)
</span><span class="add">+ >>> print schema.Descriptor(myType).__doc__
+ Descriptor(DateTime)
</span><span class="cx">
Note that you cannot use arbitrary Python types or classes; you must either
supply a ``schema.TypeReference``, a subclass of ``schema.Item``, or a
string representing a forward reference::
</span><span class="rem">- >>> schema.Role(str)
</span><span class="add">+ >>> schema.Descriptor(str)
</span><span class="cx"> Traceback (most recent call last):
...
</span><span class="rem">- TypeError: ('Attribute type must be Item/Enumeration class or TypeReference', ...)
</span><span class="add">+ TypeError: ('...must be Item/Enumeration class or TypeReference',...)
</span><span class="cx">
And type references must be to types defined by the repository's core
schema::
</span><span class="lines">@@ -247,46 +227,47 @@
</span><span class="cx"> Types expressed as a string are automatically converted to
``ForwardReference`` objects::
</span><span class="rem">- >>> testRole = schema.Role("application.schema.Item")
- >>> testRole.type
- ForwardReference('application.schema.Item',<...Role object...>)
</span><span class="add">+ >>> testDescriptor = schema.Descriptor("application.schema.Item")
+ >>> testDescriptor.type
+ ForwardReference('application.schema.Item',<...Descriptor object...>)
</span><span class="cx">
Forward references compare equal to the type they reference::
</span><span class="rem">- >>> testRole.type == schema.Item
</span><span class="add">+ >>> testDescriptor.type == schema.Item
</span><span class="cx"> True
</span><span class="rem">- >>> testRole.type != schema.Item
</span><span class="add">+ >>> testDescriptor.type != schema.Item
</span><span class="cx"> False
Aspect Attributes
</span><span class="rem">- Role objects support setting all of the aspects of a repository
</span><span class="add">+ Descriptor objects support setting all of the aspects of a repository
</span><span class="cx"> ``Attribute``, including ``required``, ``persisted``, ``indexed``,
``cardinality``, ``defaultValue``, ``initialValue``, ``inheritFrom``,
``redirectTo``, ``otherName``, ``companion``, ``deletePolicy``,
``copyPolicy``, ``countPolicy``, ``type``, ``superAttribute``,
``displayName``, and ``description``. You can supply any of these as
</span><span class="rem">- keyword arguments to a Role constructor (such as ``schema.One``,
</span><span class="add">+ keyword arguments to a Descriptor constructor (such as ``schema.One``,
</span><span class="cx"> ``schema.Many``, etc.), in order to set the corresponding value for the
attribute. Unspecified aspects will take on their normal default values,
except for ``otherName``, which is set to ``inverse.name`` by default, if
the attribute has an inverse.
</span><span class="rem">-To avoid silent definition errors, ``Role`` classes will not allow setting
-attributes that are not defined by their class::
</span><span class="add">+To avoid silent definition errors, ``Descriptor`` classes will not allow
+setting attributes that are not defined by their class::
</span><span class="cx">
</span><span class="rem">- >>> r = schema.Role(foo="bar")
</span><span class="add">+ >>> r = schema.Descriptor(foo="bar")
</span><span class="cx"> Traceback (most recent call last):
...
</span><span class="rem">- TypeError: 'foo' is not a public attribute of 'Role' objects
</span><span class="add">+ TypeError: 'foo' is not a public attribute of 'Descriptor' objects
</span><span class="cx">
</span><span class="rem">-And, to avoid unintentional alterations, Role attributes can be set only once::
</span><span class="add">+And, to avoid unintentional alterations, Descriptor attributes can be set only
+once::
</span><span class="cx">
</span><span class="rem">- >>> r = schema.Role(doc="x")
</span><span class="add">+ >>> r = schema.Descriptor(doc="x")
</span><span class="cx"> >>> r.doc = "testing"
Traceback (most recent call last):
...
</span><span class="rem">- TypeError: Role objects are immutable; can't change 'doc' ... once set
</span><span class="add">+ TypeError: Descriptor objects are immutable; can't change 'doc'... once set
</span><span class="cx">
---------------
</span><span class="lines">@@ -305,7 +286,7 @@
</span><span class="cx"> ... children = schema.Sequence(inverse=parents)
...
... schema.addClouds(
</span><span class="rem">- ... # endpoints can be defined using Role objects or strings
</span><span class="add">+ ... # endpoints can be defined using Descriptor objects or strings
</span><span class="cx"> ... sharing = schema.Cloud(byCloud=[parents,children]),
... export = schema.Cloud(byRef=["children"]),
... )
</span><span class="lines">@@ -665,7 +646,7 @@
</span><span class="cx"> >>> imp.description
'Description goes here'
</span><span class="rem">- >>> test_role = schema.Role(Importance)
</span><span class="add">+ >>> test_role = schema.Descriptor(Importance)
</span><span class="cx">
>>> imp.values
['high', 'medium', 'low']
</span><span class="lines">@@ -1055,7 +1036,7 @@
</span><span class="cx"> True
</span><span class="rem">- Meanwhile, ``schema.itemFor(aRole)`` returns a repository ``Attribute``
</span><span class="add">+ Meanwhile, ``schema.itemFor(aDescriptor)`` returns a repository ``Attribute``
</span><span class="cx"> object representing that attribute in the null view::
>>> schema.itemFor(Kind.subkinds, rv)
</span><span class="lines">@@ -1079,7 +1060,7 @@
</span><span class="cx"> >>> schema.itemFor(Kind.subkinds, rv).description is Kind.subkinds.doc
True
</span><span class="rem">- Roles must be activated in a class, however, in order to generate their
</span><span class="add">+ Descriptors must be activated in a class, however, in order to generate their
</span><span class="cx"> ``Attribute``::
>>> schema.itemFor(schema.One(), rv)
</span><span class="lines">@@ -1093,7 +1074,7 @@
</span><span class="cx"> >>> Kind.subkinds.redirectTo = "xyz"
Traceback (most recent call last):
...
</span><span class="rem">- TypeError: Role object <Role subkinds of <class '...Kind'>> cannot be modified after use
</span><span class="add">+ TypeError: Descriptor object <Descriptor subkinds of <class '...Kind'>> cannot be modified after use
</span><span class="cx">
``initRepository(repoView)``
Ensure that the given repository view has been initialized with the core
</span><span class="lines">@@ -1230,8 +1211,8 @@
</span><span class="cx">
>>> class Test1(object):
... __metaclass__ = schema.Activator
</span><span class="rem">- ... aRole = MockAttr()
- activated 'aRole' in <class 'Test1'>
</span><span class="add">+ ... aDescriptor = MockAttr()
+ activated 'aDescriptor' in <class 'Test1'>
</span><span class="cx">
>>> class Test2(Test1):
... test = MockAttr()
</span></pre></div>
<a id="trunkchandlerapplicationtestsTestSchemaAPIpy"></a>
<div class="modfile"><h4>Modified: trunk/chandler/application/tests/TestSchemaAPI.py (8756 => 8757)</h4>
<pre class="diff">
<span class="info">--- trunk/chandler/application/tests/TestSchemaAPI.py 2005-12-19 18:28:47 UTC (rev 8756)
+++ trunk/chandler/application/tests/TestSchemaAPI.py 2005-12-19 18:59:29 UTC (rev 8757)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx"> self.rv.findPath('//Schema/Core/Text'))
self.assertEqual(schema.itemFor(Other.thing, self.rv).getAspect('type'),
schema.itemFor(Dummy, self.rv))
</span><span class="rem">- self.assertRaises(TypeError, schema.Role, str)
</span><span class="add">+ self.assertRaises(TypeError, schema.Descriptor, str)
</span><span class="cx">
def testImportAll(self):
schema.initRepository(self.rv)
</span></pre></div>
<a id="trunkchandlerparcelsfeedschannelspy"></a>
<div class="modfile"><h4>Modified: trunk/chandler/parcels/feeds/channels.py (8756 => 8757)</h4>
<pre class="diff">
<span class="info">--- trunk/chandler/parcels/feeds/channels.py 2005-12-19 18:28:47 UTC (rev 8756)
+++ trunk/chandler/parcels/feeds/channels.py 2005-12-19 18:59:29 UTC (rev 8757)
</span><span class="lines">@@ -118,8 +118,8 @@
</span><span class="cx"> sharing = schema.Cloud(author, copyright, link, url)
)
</span><span class="rem">- who = schema.Role(redirectTo="author")
- about = schema.Role(redirectTo="about")
</span><span class="add">+ who = schema.Descriptor(redirectTo="author")
+ about = schema.Descriptor(redirectTo="about")
</span><span class="cx">
def Update(self, data=None):
#getattr returns a unicode object which needs to be converted to bytes for
</span><span class="lines">@@ -292,9 +292,9 @@
</span><span class="cx"> displayName=u"Content"
)
</span><span class="rem">- about = schema.Role(redirectTo="displayName")
- who = schema.Role(redirectTo="author")
- body = schema.Role(redirectTo="content")
</span><span class="add">+ about = schema.Descriptor(redirectTo="displayName")
+ who = schema.Descriptorence::
</span><span class="rem">- >>> testRole.type == schema.Item
</span><span class="add">+ >>> testDescriptor.type == schema.Item
</span><span class="cx"> True
</span><span class="rem">- >>> testRole.type != schema.Item
</span><span class="add">+ >>> testDescriptor.type != schema.Item
</span><span class="cx"> False
Aspect Attributes
</span><span class="rem">- Role objects support setting all of the aspects of a repository
</span><span class="add">+ Descriptor objects support setting all of the aspects of a repository
</span><span class="cx"> ``Attribute``, including ``required``, ``persisted``, ``indexed``,
``cardinality``, ``defaultValue``, ``initialValue``, ``inheritFrom``,
``redirectTo``, ``otherName``, ``companion``, ``deletePolicy``,
``copyPolicy``, ``countPolicy``, ``type``, ``superAttribute``,
``displayName``, and ``description``. You can supply any of these as
</span><span class="rem">- keyword arguments to a Role constructor (such as ``schema.One``,
</span><span class="add">+ keyword arguments to a Descriptor constructor (such as ``schema.One``,
</span><span class="cx"> ``schema.Many``, etc.), in order to set the corresponding value for the
attribute. Unspecified aspects will take on their normal default values,
except for ``otherName``, which is set to ``inverse.name`` by default, if
the attribute has an inverse.
</span><span class="rem">-To avoid silent definition errors, ``Role`` cl=> |
Fri, 10 Nov, 20:57 |
| foundation.org |
riptor object %r cannot be modified after use" % self
</span><span class="cx"> )
self._setattr(attr, value)
</span><span class="lines">@@ -261,7 +261,7 @@
</span><span class="cx">
def __repr__(self):
if self.name and self.owner:
</span><span class="rem">- return "<Role %s of %s>" % (self.name,self.owner)
</span><span class="add">+ return "<Descriptor %s of %s>" % (self.name,self.owner)
</span><span class="cx"> return object.__repr__(self)
def __setDoc(self,val):
</span><span class="lines">@@ -357,19 +357,19 @@
</span><span class="cx"> itemFor(self.inverse, view)
</span><span class="rem">-class One(Role):
</span><span class="add">+class One(Descriptor):
</span><span class="cx"> cardinality = 'single'
</span><span class="rem">-class Many(Role):
</span><span class="add">+class Many(Descriptor):
</span><span class="cx"> cardinality = 'set'
</span><span class="rem">-class Sequence(Role):
</span><span class="add">+class Sequence(Descriptor):
</span><span class="cx"> cardinality = 'list'
</span><span class="rem">-class Mapping(Role):
</span><span class="add">+class Mapping(Descriptor):
</span><span class="cx"> cardinality = 'dict'
</span><span class="lines">@@ -411,7 +411,7 @@
</span><span class="cx">
class AttributeAsEndpoint(Endpoint):
</span><span class="rem">- """Adapt a Role or attribute name to use as an Endpoint factory"""
</span><span class="add">+ """Adapt a Descriptor or attribute name to use as an Endpoint factory"""
</span><span class="cx">
def __new__(cls, attr, policy):
if isinstance(attr, Endpoint):
</span><span class="lines">@@ -423,7 +423,7 @@
</span><span class="cx"> def __init__(self, attr, policy):
if isinstance(attr,str):
super(AttributeAsEndpoint,self).__init__(attr,(attr,), policy)
</span><span class="rem">- elif isinstance(attr,Role):
</span><span class="add">+ elif isinstance(attr,Descriptor):
</span><span class="cx"> self.attr = attr
super(AttributeAsEndpoint,self).__init__(None,(),policy)
else:
</span><span class="lines">@@ -525,7 +525,7 @@
</span><span class="cx"> kind.classes = {'python': cls }
kind.attributes = []
for name,attr in cls.__dict__.items():
</span><span class="rem">- if isinstance(attr,Role):
</span><span class="add">+ if isinstance(attr,Descriptor):
</span><span class="cx"> ai = itemFor(attr, view)
if ai not in kind.attributes:
kind.attributes.append(ai,name)
</span><span class="lines">@@ -689,7 +689,7 @@
</span><span class="cx">
def __init__(cls,name,bases,cdict):
for name,ob in cdict.items():
</span><span class="rem">- if isinstance(ob,Role):
</span><span class="add">+ if isinstance(ob,Descriptor):
</span><span class="cx"> basename = "%s.%s." % (parcel_name(cls.__module__), cls.__name__)
ob.annotates = _target_type(cls),
ob.activateInClass(cls,basename+name)
</span><span class="lines">@@ -1182,7 +1182,7 @@
</span><span class="cx">
def _create_schema_item(self,view):
# Create a temporary item without a kind, so as not to
</span><span class="rem">- # incur unintended
</span><span class="add">+ # incur unintended circularities.
</span><span class="cx"> return Base("tmp_parcel_for-"+self.moduleName, view, None)
def _init_schema_item(self,item,view):
</span></pre></div>
<a id="trunkchandlerapplicationschema_apitxt"></a>
<div class="modfile"><h4>Modified: trunk/chandler/application/schema_api.txt (8756 => 8757)</h4>
<pre class="diff">
<span class="info">--- trunk/chandler/application/schema_api.txt 2005-12-19 18:28:47 UTC (rev 8756)
+++ trunk/chandler/application/schema_api.txt 2005-12-19 18:59:29 UTC (rev 8757)
</span><span class="lines">@@ -8,36 +8,15 @@
</span><span class="cx"> >>> from repository.persistence.RepositoryView import NullRepositoryView
</span><span class="rem">-------------
-Introduction
-------------
</span><span class="add">+------------------
+Descriptor Objects
+------------------
</span><span class="cx">
</span><span class="rem">-TODO
</span><span class="add">+The ``Descriptor`` Base Type
+=============================
</span><span class="cx">
</span><span class="rem">-------------
-Role Objects
-------------
-
-The ``One``, ``Many``, ``Sequence``, and ``Mapping`` classes are all used to
-define roles. They are all essentially identical except for their
-``cardinality`` attribute, which controls how the repository will store the
-attribute's value::
-
- >>> schema.One.cardinality
- 'single'
- >>> schema.Many.cardinality
- 'set'
- >>> schema.Sequence.cardinality
- 'list'
- >>> schema.Mapping.cardinality
- 'dict'
-
-
-The ``Role`` Base Type
-======================
-
-The base class for roles is ``schema.Role``. It provides most of the
-default behavior of roles, so rather than duplicate examples for each
</span><span class="add">+The base class for roles is ``schema.Descriptor``. It provides most of the
+default behavior of descriptors, so rather than duplicate examples for each
</span><span class="cx"> individual role type, we'll examine the default behaviors here.
All role objects have at least the following attributes and methods:
</span><span class="lines">@@ -47,39 +26,40 @@
</span><span class="cx"> relationship, or ``None`` if the role has not been registered with a
class yet::
</span><span class="rem">- >>> role = schema.Role()
</span><span class="add">+ >>> role = schema.Descriptor()
</span><span class="cx"> >>> print role.name
None
>>> class anEntity(schema.Item):
</span><span class="rem">- ... aRole = role
</span><span class="add">+ ... aDescriptor = role
</span><span class="cx"> >>> role.name
</span><span class="rem">- 'aRole'
</span><span class="add">+ 'aDescriptor'
</span><span class="cx">
``owner`` (read-only)
The entity or relationship class in which the role was defined, or ``None``
if the role has not been registered with a class yet::
</span><span class="rem">- >>> role = schema.Role()
</span><span class="add">+ >>> role = schema.Descriptor()
</span><span class="cx"> >>> print role.owner
None
>>> class anEntity(schema.Item):
</span><span class="rem">- ... aRole = role
</span><span class="add">+ ... aDescriptor = role
</span><span class="cx"> >>> role.owner
<class '...anEntity'>
</span><span class="rem">- If a role's owner is an ``Item`` class, then setting ``aRole.inverse`` will
- invoke ``aRole.inverse.addType(aRole.owner)``, so that the inverse role
- will accept instances of the first role's owning type. This allows you
</span><span class="add">+ If a role's owner is an ``Item`` class, then setting
+ ``aDescriptor.inverse`` will invoke
+ ``aDescriptor.inverse.addType(aDescriptor.owner)``, so that the inverse
+ role will accept instances of the first role's owning type. This allows you
</span><span class="cx"> to easily define bidirectional links without "forward references"; just
leave off the `type` argument in both role definitions, and specify an
`inverse` argument for the second::
>>> class anotherEntity(schema.Item):
</span><span class="rem">- ... otherRole = schema.Role(inverse=anEntity.aRole)
- >>> anotherEntity.otherRole.type
</span><span class="add">+ ... otherDescriptor=schema.Descriptor(inverse=anEntity.aDescriptor)
+ >>> anotherEntity.otherDescriptor.type
</span><span class="cx"> <class '...anEntity'>
</span><span class="rem">- >>> anEntity.aRole.type
</span><span class="add">+ >>> anEntity.aDescriptor.type
</span><span class="cx"> <class '...anotherEntity'>
As you can see, this ensures that both roles can accept the owning type of
</span><span class="lines">@@ -115,17 +95,17 @@
</span><span class="cx"> | ...
| Data and other attributes defined here:
|
</span><span class="rem">- | name = <Role name of <class '...Kind'>>
</span><span class="add">+ | name = <Descriptor name of <class '...Kind'>>
</span><span class="cx"> | Kind Name -- One(Text)
|
| This kind's name
|
</span><span class="rem">- | subkinds = <Role subkinds of <class '...Kind'>>
</span><span class="add">+ | subkinds = <Descriptor subkinds of <class '...Kind'>>
</span><span class="cx"> | Many(Kind)
|
| Sub-kinds of this kind
|
</span><span class="rem">- | superkinds = <Role superkinds of <class '...Kind'>>
</span><span class="add">+ | superkinds = <Descriptor superkinds of <class '...Kind...
</span><span class="cx"> | Many(Kind)
|
| Super-kinds of this kind
</span><span class="lines">@@ -139,7 +119,7 @@
</span><span class="cx">
The ``doc`` and ``description`` are always strings, even if empty::
</span><span class="rem">- >>> schema.Role().description
</span><span class="add">+ >>> schema.Descriptor().description
</span><span class="cx"> ''
``inverse``
</span><span class="lines">@@ -152,10 +132,10 @@
</span><span class="cx"> ``inverse`` can be set via keyword argument to the role class'
constructor::
</span><span class="rem">- >>> role1 = schema.Role()
</span><span class="add">+ >>> role1 = schema.Descriptor()
</span><span class="cx"> >>> print role1.inverse
None
</span><span class="rem">- >>> role2 = schema.Role(inverse=role1)
</span><span class="add">+ >>> role2 = schema.Descriptor(inverse=role1)
</span><span class="cx"> >>> role2.inverse is role1
True
>>> role1.inverse is role2
</span><span class="lines">@@ -163,8 +143,8 @@
</span><span class="cx">
Or by setting the ``inverse`` attribute after construction::
</span><span class="rem">- >>> role1 = schema.Role()
- >>> role2 = schema.Role()
</span><span class="add">+ >>> role1 = schema.Descriptor()
+ >>> role2 = schema.Descriptor()
</span><span class="cx"> >>> role2.inverse = role1
>>> role2.inverse is role1
True
</span><span class="lines">@@ -173,23 +153,23 @@
</span><span class="cx">
Once set, it cannot be changed, unless it is to the same role::
</span><span class="rem">- >>> role2.inverse = schema.Role()
</span><span class="add">+ >>> role2.inverse = schema.Descriptor()
</span><span class="cx"> Traceback (most recent call last):
...
</span><span class="rem">- TypeError: Role objects are immutable; can't change 'inverse' ... once set
</span><span class="add">+ TypeError: Descriptor objects are immutable; can't change 'inverse' ...
</span><span class="cx">
>>> role2.inverse is role1 # no change took place
True
And trying to insert a new role into an existing pair also fails::
</span><span class="rem">- >>> role3 = schema.Role()
</span><span class="add">+ >>> role3 = schema.Descriptor()
</span><span class="cx"> >>> print role3.inverse
None
>>> role3.inverse = role2
Traceback (most recent call last):
...
</span><span class="rem">- TypeError: Role objects are immutable; can't change 'inverse' ... once set
</span><span class="add">+ TypeError: Descriptor objects are immutable; can't change 'inverse' ...
</span><span class="cx">
>>> print role3.inverse # no change took place
None
</span><span class="lines">@@ -210,7 +190,7 @@
</span><span class="cx"> <class '...Folder'>
>>> File.folder.inverse
</span><span class="rem">- <Role contents of <class '...Folder'>>
</span><span class="add">+ <Descriptor contents of <class '...Folder'>>
</span><span class="cx">
``type``
The ``type`` of a role can be either a ``schema.Item`` subclass, a
</span><span class="lines">@@ -224,17 +204,17 @@
</span><span class="cx">
>>> myType = schema.TypeReference('//Schema/Core/DateTime')
</span><span class="rem">- >>> print schema.Role(myType).__doc__
- Role(DateTime)
</span><span class="add">+ >>> print schema.Descriptor(myType).__doc__
+ Descriptor(DateTime)
</span><span class="cx">
Note that you cannot use arbitrary Python types or classes; you must either
supply a ``schema.TypeReference``, a subclass of ``schema.Item``, or a
string representing a forward reference::
</span><span class="rem">- >>> schema.Role(str)
</span><span class="add">+ >>> schema.Descriptor(str)
</span><span class="cx"> Traceback (most recent call last):
...
</span><span class="rem">- TypeError: ('Attribute type must be Item/Enumeration class or TypeReference', ...)
</span><span class="add">+ TypeError: ('...must be Item/Enumeration class or TypeReference',...)
</span><span class="cx">
And type references must be to types defined by the repository's core
schema::
</span><span class="lines">@@ -247,46 +227,47 @@
</span><span class="cx"> Types expressed as a string are automatically converted to
``ForwardReference`` objects::
</span><span class="rem">- >>> testRole = schema.Role("application.schema.Item")
- >>> testRole.type
- ForwardReference('application.schema.Item',<...Role object...>)
</span><span class="add">+ >>> testDescriptor = schema.Descriptor("application.schema.Item")
+ >>> testDescriptor.type
+ ForwardReference('application.schema.Item',<...Descriptor object...>)
</span><span class="cx">
Forward references compare equal to the type they reference::
</span><span class="rem">- >>> testRole.type == schema.Item
</span><span class="add">+ >>> testDescriptor.type == schema.Item
</span><span class="cx"> True
</span><span class="rem">- >>> testRole.type != schema.Item
</span><span class="add">+ >>> testDescriptor.type != schema.Item
</span><span class="cx"> False
Aspect Attributes
</span><span class="rem">- Role objects support setting all of the aspects of a repository
</span><span class="add">+ Descriptor objects support setting all of the aspects of a repository
</span><span class="cx"> ``Attribute``, including ``required``, ``persisted``, ``indexed``,
``cardinality``, ``defaultValue``, ``initialValue``, ``inheritFrom``,
``redirectTo``, ``otherName``, ``companion``, ``deletePolicy``,
``copyPolicy``, ``countPolicy``, ``type``, ``superAttribute``,
``displayName``, and ``description``. You can supply any of these as
</span><span class="rem">- keyword arguments to a Role constructor (such as ``schema.One``,
</span><span class="add">+ keyword arguments to a Descriptor constructor (such as ``schema.One``,
</span><span class="cx"> ``schema.Many``, etc.), in order to set the corresponding value for the
attribute. Unspecified aspects will take on their normal default values,
except for ``otherName``, which is set to ``inverse.name`` by default, if
the attribute has an inverse.
</span><span class="rem">-To avoid silent definition errors, ``Role`` classes will not allow setting
-attributes that are not defined by their class::
</span><span class="add">+To avoid silent definition errors, ``Descriptor`` classes will not allow
+setting attributes that are not defined by their class::
</span><span class="cx">
</span><span class="rem">- >>> r = schema.Role(foo="bar")
</span><span class="add">+ >>> r = schema.Descriptor(foo="bar")
</span><span class="cx"> Traceback (most recent call last):
...
</span><span class="rem">- TypeError: 'foo' is not a public attribute of 'Role' objects
</span><span class="add">+ TypeError: 'foo' is not a public attribute of 'Descriptor' objects
</span><span class="cx">
</span><span class="rem">-And, to avoid unintentional alterations, Role attributes can be set only once::
</span><span class="add">+And, to avoid unintentional alterations, Descriptor attributes can be set only
+once::
</span><span class="cx">
</span><span class="rem">- >>> r = schema.Role(doc="x")
</span><span class="add">+ >>> r = schema.Descriptor(doc="x")
</span><span class="cx"> >>> r.doc = "testing"
Traceback (most recent call last):
...
</span><span class="rem">- TypeError: Role objects are immutable; can't change 'doc' ... once set
</span><span class="add">+ TypeError: Descriptor objects are immutable; can't change 'doc'... once set
</span><span class="cx">
---------------
</span><span class="lines">@@ -305,7 +286,7 @@
</span><span class="cx"> ... children = schema.Sequence(inverse=parents)
...
... schema.addClouds(
</span><span class="rem">- ... # endpoints can be defined using Role objects or strings
</span><span class="add">+ ... # endpoints can be defined using Descriptor objects or strings
</span><span class="cx"> ... sharing = schema.Cloud(byCloud=[parents,children]),
... export = schema.Cloud(byRef=["children"]),
... )
</span><span class="lines">@@ -665,7 +646,7 @@
</span><span class="cx"> >>> imp.description
'Description goes here'
</span><span class="rem">- >>> test_role = schema.Role(Importance)
</span><span class="add">+ >>> test_role = schema.Descriptor(Importance)
</span><span class="cx">
>>> imp.values
['high', 'medium', 'low']
</span><span class="lines">@@ -1055,7 +1036,7 @@
</span><span class="cx"> True
</span><span class="rem">- Meanwhile, ``schema.itemFor(aRole)`` returns a repository ``Attribute``
</span><span class="add">+ Meanwhile, ``schema.itemFor(aDescriptor)`` returns a repository ``Attribute``
</span><span class="cx"> object representing that attribute in the null view::
>>> schema.itemFor(Kind.subkinds, rv)
</span><span class="lines">@@ -1079,7 +1060,7 @@
</span><span class="cx"> >>> schema.itemFor(Kind.subkinds, rv).description is Kind.subkinds.doc
True
</span><span class="rem">- Roles must be activated in a class, however, in order to generate their
</span><span class="add">+ Descriptors must be activated in a class, however, in order to generate their
</span><span class="cx"> ``Attribute``::
>>> schema.itemFor(schema.One(), rv)
</span><span class="lines">@@ -1093,7 +1074,7 @@
</span><span class="cx"> >>> Kind.subkinds.redirectTo = "xyz"
Traceback (most recent call last):
...
</span><span class="rem">- TypeError: Role object <Role subkinds of <class '...Kind'>> cannot be modified after use
</span><span class="add">+ TypeError: Descriptor object <Descriptor subkinds of <class '...Kind'>> cannot be modified after use
</span><span class="cx">
``initRepository(repoView)``
Ensure that the given repository view has been initialized with the core
</span><span class="lines">@@ -1230,8 +1211,8 @@
</span><span class="cx">
>>> class Test1(object):
... __metaclass__ = schema.Activator
</span><span class="rem">- ... aRole = MockAttr()
- activated 'aRole' in <class 'Test1'>
</span><span class="add">+ ... aDescriptor = MockAttr()
+ activated 'aDescriptor' in <class 'Test1'>
</span><span class="cx">
>>> class Test2(Test1):
... test = MockAttr()
</span></pre></div>
<a id="trunkchandlerapplicationtestsTestSchemaAPIpy"></a>
<div class="modfile"><h4>Modified: trunk/chandler/application/tests/TestSchemaAPI.py (8756 => 8757)</h4>
<pre class="diff">
<span class="info">--- trunk/chandler/application/tests/TestSchemaAPI.py 2005-12-19 18:28:47 UTC (rev 8756)
+++ trunk/chandler/application/tests/TestSchemaAPI.py 2005-12-19 18:59:29 UTC (rev 8757)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx"> self.rv.findPath('//Schema/Core/Text'))
self.assertEqual(schema.itemFor(Other.thing, self.rv).getAspect('type'),
schema.itemFor(Dummy, self.rv))
</span><span class="rem">- self.assertRaises(TypeError, schema.Role, str)
</span><span class="add">+ self.assertRaises(TypeError, schema.Descriptor, str)
</span><span class="cx">
def testImportAll(self):
schema.initRepository(self.rv)
</span></pre></div>
<a id="trunkchandlerparcelsfeedschannelspy"></a>
<div class="modfile"><h4>Modified: trunk/chandler/parcels/feeds/channels.py (8756 => 8757)</h4>
<pre class="diff">
<span class="info">--- trunk/chandler/parcels/feeds/channels.py 2005-12-19 18:28:47 UTC (rev 8756)
+++ trunk/chandler/parcels/feeds/channels.py 2005-12-19 18:59:29 UTC (rev 8757)
</span><span class="lines">@@ -118,8 +118,8 @@
</span><span class="cx"> sharing = schema.Cloud(author, copyright, link, url)
)
</span><span class="rem">- who = schema.Role(redirectTo="author")
- about = schema.Role(redirectTo="about")
</span><span class="add">+ who = schema.Descriptor(redirectTo="author")
+ about = schema.Descriptor(redirectTo="about")
</span><span class="cx">
def Update(self, data=None):
#getattr returns a unicode object which needs to be converted to bytes for
</span><span class="lines">@@ -292,9 +292,9 @@
</span><span class="cx"> displayName=u"Content"
)
</span><span class="rem">- about = schema.Role(redirectTo="displayName")
- who = schema.Role(redirectTo="author")
- body = schema.Role(redirectTo="content")
</span><span class="add">+ about = schema.Descriptor(redirectTo="displayName")
+ who = schema.Descriptorence::
</span><span class="rem">- >>> testRole.type == schema.Item
</span><span class="add">+ >>> testDescriptor.type == schema.Item
</span><span class="cx"> True
</span><span class="rem">- >>> testRole.type != schema.Item
</span><span class="add">+ >>> testDescriptor.type != schema.Item
</span><span class="cx"> False
Aspect Attributes
</span><span class="rem">- Role objects support setting all of the aspects of a repository
</span><span class="add">+ Descriptor objects support setting all of the aspects of a repository
</span><span class="cx"> ``Attribute``, including ``required``, ``persisted``, ``indexed``,
``cardinality``, ``defaultValue``, ``initialValue``, ``inheritFrom``,
``redirectTo``, ``otherName``, ``companion``, ``deletePolicy``,
``copyPolicy``, ``countPolicy``, ``type``, ``superAttribute``,
``displayName``, and ``description``. You can supply any of these as
</span><span class="rem">- keyword arguments to a Role constructor (such as ``schema.One``,
</span><span class="add">+ keyword arguments to a Descriptor constructor (such as ``schema.One``,
</span><span class="cx"> ``schema.Many``, etc.), in order to set the corresponding value for the
attribute. Unspecified aspects will take on their normal default values,
except for ``otherName``, which is set to ``inverse.name`` by default, if
the attribute has an inverse.
</span><span class="rem">-To avoid silent definition errors, ``Role`` cl=> |
Fri, 10 Nov, 20:57 |