[Commits] (vajda) renamed Kind.isSubKindOf() to Kind.isKindOf() and fixed Kind.iterAttributes() to not duplicate or miss things

commits at osafoundation.org commits at osafoundation.org
Tue Apr 27 19:47:11 PDT 2004


Commit by: vajda
Modified files:
osaf/chandler/Chandler/repository/item/Item.py 1.119 1.120
osaf/chandler/Chandler/repository/item/ItemRef.py 1.66 1.67
osaf/chandler/Chandler/repository/schema/Kind.py 1.62 1.63
osaf/chandler/Chandler/repository/tests/TestKinds.py 1.4 1.5

Log message:
renamed Kind.isSubKindOf() to Kind.isKindOf() and fixed Kind.iterAttributes() to not duplicate or miss things


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/item/Item.py.diff?r1=text&tr1=1.119&r2=text&tr2=1.120
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/item/ItemRef.py.diff?r1=text&tr1=1.66&r2=text&tr2=1.67
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/schema/Kind.py.diff?r1=text&tr1=1.62&r2=text&tr2=1.63
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/tests/TestKinds.py.diff?r1=text&tr1=1.4&r2=text&tr2=1.5

Index: osaf/chandler/Chandler/repository/item/ItemRef.py
diff -u osaf/chandler/Chandler/repository/item/ItemRef.py:1.66 osaf/chandler/Chandler/repository/item/ItemRef.py:1.67
--- osaf/chandler/Chandler/repository/item/ItemRef.py:1.66	Fri Apr  9 12:22:36 2004
+++ osaf/chandler/Chandler/repository/item/ItemRef.py	Tue Apr 27 19:46:39 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.66 $"
-__date__      = "$Date: 2004/04/09 19:22:36 $"
+__revision__  = "$Revision: 1.67 $"
+__date__      = "$Date: 2004/04/28 02:46:39 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -598,7 +598,7 @@
                          value.other(self._item), self._otherName)
 
         link = super(RefDict, self).__delitem__(key)
-        if link._alias:
+        if link._alias is not None:
             del self._aliases[link._alias]
             
         self._count -= 1

Index: osaf/chandler/Chandler/repository/schema/Kind.py
diff -u osaf/chandler/Chandler/repository/schema/Kind.py:1.62 osaf/chandler/Chandler/repository/schema/Kind.py:1.63
--- osaf/chandler/Chandler/repository/schema/Kind.py:1.62	Fri Apr 23 11:21:37 2004
+++ osaf/chandler/Chandler/repository/schema/Kind.py	Tue Apr 27 19:46:40 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.62 $"
-__date__      = "$Date: 2004/04/23 18:21:37 $"
+__revision__  = "$Revision: 1.63 $"
+__date__      = "$Date: 2004/04/28 02:46:40 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -126,30 +126,32 @@
         @type globalOnly: boolean
         """
 
-        if inherited:
-            inheritedAttributes = self.inheritedAttributes
-            for superKind in self._getSuperKinds():
-                for name, attribute in superKind.iterAttributes(inherited,
-                                                                localOnly,
-                                                                globalOnly):
-                    if not attribute.itsUUID in inheritedAttributes:
-                        inheritedAttributes.append(attribute, alias=name)
-                    yield (name, attribute)
-
         attributes = self.getAttributeValue('attributes', default=None)
         if attributes is not None:
 
-            if not localOnly:
-                aliases = attributes._aliases
-                if aliases:
-                    for (alias, uuid) in aliases.iteritems():
-                        yield (alias, attributes[uuid])
-    
             if not globalOnly:
                 for attribute in self.iterChildren():
                     if attribute._uuid in attributes:
                         yield (attribute._name, attribute)
 
+            if not localOnly:
+                for attribute in attributes:
+                    if attribute.itsParent is not self:
+                        yield (attributes._get(attribute._uuid)._alias,
+                               attribute)
+
+        if inherited:
+            inheritedAttributes = self.inheritedAttributes
+            for superKind in self._getSuperKinds():
+                for name, attribute in superKind.iterAttributes():
+                    if not attribute._uuid in inheritedAttributes:
+                        inheritedAttributes.append(attribute, alias=name)
+            for uuid, link in inheritedAttributes._iteritems():
+                name = link._alias
+                if (not self.hasChild(name) and
+                    attributes and not attributes.resolveAlias(name)):
+                    yield (name, link._value.other(self))
+
     def _inheritAttribute(self, name):
 
         if self.hasValue('notFoundAttributes', name):
@@ -189,7 +191,10 @@
 
         return False
 
-    def isSubKindOf(self, superKind):
+    def isKindOf(self, superKind):
+
+        if self is superKind:
+            return True
 
         superKinds = self._getSuperKinds()
 
@@ -199,7 +204,7 @@
                     return True
 
             for kind in superKinds:
-                if kind.isSubKindOf(superKind):
+                if kind.isKindOf(superKind):
                     return True
 
         return False

Index: osaf/chandler/Chandler/repository/tests/TestKinds.py
diff -u osaf/chandler/Chandler/repository/tests/TestKinds.py:1.4 osaf/chandler/Chandler/repository/tests/TestKinds.py:1.5
--- osaf/chandler/Chandler/repository/tests/TestKinds.py:1.4	Tue Mar 23 21:08:55 2004
+++ osaf/chandler/Chandler/repository/tests/TestKinds.py	Tue Apr 27 19:46:41 2004
@@ -2,8 +2,8 @@
 Unit tests for kinds
 """
 
-__revision__  = "$Revision: 1.4 $"
-__date__      = "$Date: 2004/03/24 05:08:55 $"
+__revision__  = "$Revision: 1.5 $"
+__date__      = "$Date: 2004/04/28 02:46:41 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -80,12 +80,12 @@
         """ A kind is not an alias """
         self.assert_(not self.kind1.isAlias())
     
-    def testIsSubKindOf(self):
-        """ Test IsSubKindOf on multiple super kinds """
+    def testIsKindOf(self):
+        """ Test IsKindOf on multiple super kinds """
         # make kind2 a subkind of kind1
         self.kind2.addValue('superKinds', self.kind1)
-        self.assert_(self.kind2.isSubKindOf(self.itemKind))
-        self.assert_(self.kind2.isSubKindOf(self.kind1))
+        self.assert_(self.kind2.isKindOf(self.itemKind))
+        self.assert_(self.kind2.isKindOf(self.kind1))
 
 
     def testToXML(self):

Index: osaf/chandler/Chandler/repository/item/Item.py
diff -u osaf/chandler/Chandler/repository/item/Item.py:1.119 osaf/chandler/Chandler/repository/item/Item.py:1.120
--- osaf/chandler/Chandler/repository/item/Item.py:1.119	Fri Apr 23 11:21:32 2004
+++ osaf/chandler/Chandler/repository/item/Item.py	Tue Apr 27 19:46:39 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.119 $"
-__date__      = "$Date: 2004/04/23 18:21:32 $"
+__revision__  = "$Revision: 1.120 $"
+__date__      = "$Date: 2004/04/28 02:46:39 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -1529,7 +1529,7 @@
             return True
 
         if self._kind is not None:
-            return self._kind.isSubKindOf(kind)
+            return self._kind.isKindOf(kind)
 
         return False
 



More information about the Commits mailing list