[Commits] (vajda) - removed defaultKind feature
commits at osafoundation.org
commits at osafoundation.org
Wed Feb 16 12:41:08 PST 2005
Commit by: vajda
Modified files:
chandler/repository/item/Item.py 1.196 1.197
chandler/repository/item/ItemError.py 1.7 1.8
chandler/repository/packs/schema/model/Kind.kind 1.28 1.29
chandler/repository/schema/Kind.py 1.102 1.103
chandler/repository/tests/data/packs/cineguide/schema/kinds/Movie.kind 1.10 1.11
Log message:
- removed defaultKind feature
- reworked defaultParent feature and its error reporting
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Item.py.diff?r1=text&tr1=1.196&r2=text&tr2=1.197
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/ItemError.py.diff?r1=text&tr1=1.7&r2=text&tr2=1.8
http://cvs.osafoundation.org/index.cgi/chandler/repository/packs/schema/model/Kind.kind.diff?r1=text&tr1=1.28&r2=text&tr2=1.29
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Kind.py.diff?r1=text&tr1=1.102&r2=text&tr2=1.103
http://cvs.osafoundation.org/index.cgi/chandler/repository/tests/data/packs/cineguide/schema/kinds/Movie.kind.diff?r1=text&tr1=1.10&r2=text&tr2=1.11
Index: chandler/repository/packs/schema/model/Kind.kind
diff -u chandler/repository/packs/schema/model/Kind.kind:1.28 chandler/repository/packs/schema/model/Kind.kind:1.29
--- chandler/repository/packs/schema/model/Kind.kind:1.28 Tue Jan 11 14:11:59 2005
+++ chandler/repository/packs/schema/model/Kind.kind Wed Feb 16 12:41:04 2005
@@ -15,7 +15,7 @@
- notFoundAttributes, inheritedAttributes,
- superKinds, subKinds, attributes, classes,
- displayAttribute, clouds, otherNames, mixins,
- - defaultKind, defaultParent
+ - defaultParent
-->
</ref>
@@ -227,22 +227,6 @@
</item>
<item withSchema="True">
- <name>defaultKind</name>
- <kind type="path">//Schema/Core/Attribute</kind>
- <class module="repository.schema.Attribute">Attribute</class>
- <parent type="path">//Schema/Core/Kind</parent>
-
- <ref name="kinds" otherName="attributes"
- cardinality="list" otherCard="list">
- <ref type="path">..</ref>
- </ref>
-
- <ref name="type" otherName="typeFor"
- type="path" otherCard="list">/Core/Boolean</ref>
- <attribute name="cardinality">single</attribute>
- </item>
-
- <item withSchema="True">
<name>defaultParent</name>
<kind type="path">//Schema/Core/Attribute</kind>
<class module="repository.schema.Attribute">Attribute</class>
Index: chandler/repository/item/Item.py
diff -u chandler/repository/item/Item.py:1.196 chandler/repository/item/Item.py:1.197
--- chandler/repository/item/Item.py:1.196 Tue Feb 15 16:29:19 2005
+++ chandler/repository/item/Item.py Wed Feb 16 12:41:03 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.196 $"
-__date__ = "$Date: 2005/02/16 00:29:19 $"
+__revision__ = "$Revision: 1.197 $"
+__date__ = "$Date: 2005/02/16 20:41:03 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -46,22 +46,8 @@
# This needs to be the top of the inheritance diamond, hence we're
# not calling super() here.
- if parent is None:
- raise ValueError, 'parent cannot be None'
-
cls = type(self)
- if kind is None:
- try:
- uuid = cls.__dict__['_defaultKind']
- except KeyError:
- uuid = None
-
- if uuid is not None:
- kind = parent.find(uuid)
- if kind is None:
- raise NoSuchDefaultKindError, (self, cls)
-
self.__dict__.update({ '_status': Item.NEW,
'_version': 0L,
'_lastAccess': 0L,
@@ -74,13 +60,19 @@
if kind is not None:
kind._setupClass(cls)
- if not parent._isItem():
- if kind is not None:
- parent = kind.getAttributeValue('defaultParent', default=parent)
- if parent is None:
- raise NoSuchDefaultParentError, (self, kind)
- if name is None and not parent._isItem():
- raise ValueError, 'repository root cannot be anonymous'
+ if parent is None:
+ if kind is None:
+ raise NoParentError, self
+
+ parent = kind.getAttributeValue('defaultParent', default=Item.Nil,
+ _attrDict=kind._values)
+ if parent is None:
+ raise NoSuchDefaultParentError, (self, kind)
+ if parent is Item.Nil:
+ raise NoParentError, self
+
+ if name is None and not parent._isItem():
+ raise AnonymousRootError, self
self._setParent(parent)
Index: chandler/repository/tests/data/packs/cineguide/schema/kinds/Movie.kind
diff -u chandler/repository/tests/data/packs/cineguide/schema/kinds/Movie.kind:1.10 chandler/repository/tests/data/packs/cineguide/schema/kinds/Movie.kind:1.11
--- chandler/repository/tests/data/packs/cineguide/schema/kinds/Movie.kind:1.10 Tue Jan 11 14:12:00 2005
+++ chandler/repository/tests/data/packs/cineguide/schema/kinds/Movie.kind Wed Feb 16 12:41:05 2005
@@ -19,7 +19,6 @@
</ref>
<attribute name="displayAttribute">title</attribute>
- <attribute name="defaultKind">True</attribute>
<attribute name="classes">
<value name="python">repository.tests.classes.Movie.Movie</value>
Index: chandler/repository/item/ItemError.py
diff -u chandler/repository/item/ItemError.py:1.7 chandler/repository/item/ItemError.py:1.8
--- chandler/repository/item/ItemError.py:1.7 Mon Feb 7 20:02:54 2005
+++ chandler/repository/item/ItemError.py Wed Feb 16 12:41:03 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.7 $"
-__date__ = "$Date: 2005/02/08 04:02:54 $"
+__revision__ = "$Revision: 1.8 $"
+__date__ = "$Date: 2005/02/16 20:41:03 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -46,6 +46,20 @@
return self.__doc__ %(self.getItem().itsPath, self.args[1])
+class AnonymousRootError(ValueError, ItemError):
+ 'repository root %s may not be anonymous'
+
+ def __str__(self):
+ return self.__doc__ %(self.getItem()._repr_())
+
+
+class NoParentError(ValueError, ItemError):
+ 'While creating %s, parent is None'
+
+ def __str__(self):
+ return self.__doc__ %(self.getItem()._repr_())
+
+
class OwnedValueError(ValueError, ItemError):
"Value %s is already owned by item %s on attribute '%s'"
@@ -184,14 +198,6 @@
return self.args[0] % self.args[1:]
-class NoSuchDefaultKindError(SchemaError):
- 'While creating %s, defaultKind %s specified on class %s.%s was not found'
-
- def __str__(self):
- cls = self.args[1]
- return self.__doc__ %(self.str(self.getItem()),
- cls._defaultKind, cls.__module__, cls.__name__)
-
class NoSuchDefaultParentError(SchemaError):
'While creating %s, defaultParent %s, specified on kind %s, was not found'
Index: chandler/repository/schema/Kind.py
diff -u chandler/repository/schema/Kind.py:1.102 chandler/repository/schema/Kind.py:1.103
--- chandler/repository/schema/Kind.py:1.102 Fri Feb 4 13:39:38 2005
+++ chandler/repository/schema/Kind.py Wed Feb 16 12:41:04 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.102 $"
-__date__ = "$Date: 2005/02/04 21:39:38 $"
+__revision__ = "$Revision: 1.103 $"
+__date__ = "$Date: 2005/02/16 20:41:04 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -73,18 +73,6 @@
except KeyError:
classes[cls] = set((uuid,))
- if self._values.get('defaultKind', False):
- try:
- uuid = cls.__dict__['_defaultKind']
- except KeyError:
- cls._defaultKind = self._uuid
- else:
- if uuid != self._uuid:
- if self.find(uuid) is not None:
- raise SchemaError, ("Cannot set class %s.%s _defaultKind attribute to %s's UUID, it is already set to %s", self.itsPath, cls.__module__, cls.__name__, uuid)
- else:
- cls._defaultKind = self._uuid
-
self.monitorSchema = True
self._setupDescriptors(cls)
More information about the Commits
mailing list