[Commits] (vajda) - started moving code around in preparation for access control

commits at osafoundation.org commits at osafoundation.org
Wed Mar 31 13:24:59 PST 2004


Commit by: vajda
Modified files:
osaf/chandler/Chandler/parcels/OSAF/framework/notifications/tests/.cvsignore 1.1 1.2
osaf/chandler/Chandler/repository/item/Access.py None 1.1
osaf/chandler/Chandler/repository/item/Values.py None 1.1
osaf/chandler/Chandler/repository/item/Item.py 1.116 1.117
osaf/chandler/Chandler/repository/item/ItemHandler.py 1.33 1.34
osaf/chandler/Chandler/repository/item/ItemRef.py 1.64 1.65
osaf/chandler/Chandler/repository/item/PersistentCollections.py 1.9 1.10
osaf/chandler/Chandler/repository/parcel/tests/.cvsignore 1.1 1.2
osaf/chandler/Chandler/repository/parcel/tests/testparcels/.cvsignore None 1.1
osaf/chandler/Chandler/repository/parcel/tests/testparcels/classes/.cvsignore None 1.1
osaf/chandler/Chandler/repository/parcel/tests/testparcels/classes/super/.cvsignore None 1.1
osaf/chandler/Chandler/repository/persistence/XMLRepositoryView.py 1.31 1.32
osaf/chandler/Chandler/repository/schema/Kind.py 1.60 1.61

Log message:
   - started moving code around in preparation for access control
   - fixed indexing bug found by Stuart
   - added bunch of .cvsignore files to quiet cvs down


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/framework/notifications/tests/.cvsignore.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/item/Access.py?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/item/Values.py?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/item/Item.py.diff?r1=text&tr1=1.116&r2=text&tr2=1.117
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/item/ItemHandler.py.diff?r1=text&tr1=1.33&r2=text&tr2=1.34
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/item/ItemRef.py.diff?r1=text&tr1=1.64&r2=text&tr2=1.65
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/item/PersistentCollections.py.diff?r1=text&tr1=1.9&r2=text&tr2=1.10
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/parcel/tests/.cvsignore.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/parcel/tests/testparcels/.cvsignore?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/parcel/tests/testparcels/classes/.cvsignore?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/parcel/tests/testparcels/classes/super/.cvsignore?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/persistence/XMLRepositoryView.py.diff?r1=text&tr1=1.31&r2=text&tr2=1.32
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/schema/Kind.py.diff?r1=text&tr1=1.60&r2=text&tr2=1.61

Index: osaf/chandler/Chandler/repository/item/ItemRef.py
diff -u osaf/chandler/Chandler/repository/item/ItemRef.py:1.64 osaf/chandler/Chandler/repository/item/ItemRef.py:1.65
--- osaf/chandler/Chandler/repository/item/ItemRef.py:1.64	Fri Mar 26 16:39:24 2004
+++ osaf/chandler/Chandler/repository/item/ItemRef.py	Wed Mar 31 13:24:19 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.64 $"
-__date__      = "$Date: 2004/03/27 00:39:24 $"
+__revision__  = "$Revision: 1.65 $"
+__date__      = "$Date: 2004/03/31 21:24:19 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -420,82 +420,6 @@
             raise ValueError, value
 
         return None
-
-
-class Values(dict):
-
-    def __init__(self, item):
-
-        super(Values, self).__init__()
-        self._setItem(item)
-
-    def _setItem(self, item):
-
-        self._item = item
-
-    def _copy(self, item):
-
-        values = type(self)(item)
-        for name, value in self.iteritems():
-            if isinstance(value, ItemPackage.PersistentCollections.PersistentCollection):
-                value = value._copy(item, name, value._companion)
-            elif isinstance(value, ItemPackage.Item.ItemValue):
-                value = value._copy(item, name)
-
-            values[name] = value
-
-        return values
-
-    def _getItem(self):
-
-        return self._item
-
-    def __setitem__(self, key, value):
-
-        if self._item is not None:
-            self._item.setDirty(attribute=key)
-
-        super(Values, self).__setitem__(key, value)
-
-    def __delitem__(self, key):
-
-        if self._item is not None:
-            self._item.setDirty(attribute=key)
-
-        super(Values, self).__delitem__(key)
-
-    def _unload(self):
-
-        self.clear()
-        
-
-class References(Values):
-
-    def _setItem(self, item):
-
-        for value in self.itervalues():
-            value._setItem(item)
-
-        self._item = item
-
-    def _copy(self, item):
-
-        references = type(self)(item)
-        for name, value in self.iteritems():
-            copyPolicy = item.getAttributeAspect(name, 'copyPolicy')
-            if copyPolicy == 'copy':
-                references[name] = value._copy(item, name)
-                
-        return references
-
-    def __setitem__(self, key, value, *args):
-
-        super(References, self).__setitem__(key, value)
-
-    def _unload(self):
-
-        for value in self.itervalues():
-            value._unload(self._item)
 
 
 class RefDict(LinkedMap):

Index: osaf/chandler/Chandler/parcels/OSAF/framework/notifications/tests/.cvsignore
diff -u osaf/chandler/Chandler/parcels/OSAF/framework/notifications/tests/.cvsignore:1.1 osaf/chandler/Chandler/parcels/OSAF/framework/notifications/tests/.cvsignore:1.2
--- osaf/chandler/Chandler/parcels/OSAF/framework/notifications/tests/.cvsignore:1.1	Tue Jan 13 10:56:46 2004
+++ osaf/chandler/Chandler/parcels/OSAF/framework/notifications/tests/.cvsignore	Wed Mar 31 13:24:18 2004
@@ -1,2 +1,3 @@
 *.pyc
 *.pyo
+test.log

Index: osaf/chandler/Chandler/repository/item/Item.py
diff -u osaf/chandler/Chandler/repository/item/Item.py:1.116 osaf/chandler/Chandler/repository/item/Item.py:1.117
--- osaf/chandler/Chandler/repository/item/Item.py:1.116	Fri Mar 26 16:39:24 2004
+++ osaf/chandler/Chandler/repository/item/Item.py	Wed Mar 31 13:24:19 2004
@@ -1,13 +1,13 @@
 
-__revision__  = "$Revision: 1.116 $"
-__date__      = "$Date: 2004/03/27 00:39:24 $"
+__revision__  = "$Revision: 1.117 $"
+__date__      = "$Date: 2004/03/31 21:24:19 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
 import cStringIO
 
-from repository.item.ItemRef import ItemRef, NoneRef, RefArgs
-from repository.item.ItemRef import Values, References, RefDict
+from repository.item.ItemRef import ItemRef, NoneRef, RefArgs, RefDict
+from repository.item.Values import Values, References, ItemValue
 from repository.item.ItemHandler import ItemHandler
 from repository.item.PersistentCollections import PersistentCollection
 from repository.item.PersistentCollections import PersistentList
@@ -256,6 +256,10 @@
               references to the items stored in the mixed collection. By
               default, if the companion aspect is not set, the entire
               repository is considered. This aspect takes a string value.
+            - C{copyPolicy}: when an item is copied with the L{copy} method,
+              its reference attribute values are copied if this policy is
+              set to C{copy}. By default, C{copyPolicy} is set to
+              C{remove}. This aspect takes a string value.
             - C{deletePolicy}: when an item is deleted this policy defines
               what happens to items that are referenced by this
               attribute. Possible C{deletePolicy} values are:
@@ -1130,7 +1134,20 @@
         return False
 
     def copy(self, name=None, parent=None):
+        """
+        Copy this item.
+
+        The item's literal attribute values are copied.
+        The item's reference attribute values are copied if the
+        C{copyPolicy} aspect on the attribute is C{copy}. The C{copyPolicy}
+        is C{remove} by default.
 
+        @param name: the name of the item's copy
+        @type name: a string
+        @param parent: the parent of the item's copy, the original's parent
+        by default
+        @type parent: an item
+        """
         cls = type(self)
         item = cls.__new__(cls)
         item._fillItem(name, parent or self.itsParent, self._kind,
@@ -1305,7 +1322,12 @@
 
     def __getKind(self):
 
-        return self._kind
+        kind = self._kind
+        if kind is not None and kind._status & Item.STALE:
+            kind = self.getRepository()[kind._uuid]
+            self._kind = kind
+                
+        return kind
 
     def getRepository(self):
         """
@@ -1974,44 +1996,3 @@
             return True
 
         return False
-
-
-class ItemValue(object):
-    'A superclass for values that are owned by an item.'
-    
-    def __init__(self):
-
-        self._item = None
-        self._attribute = None
-        self._dirty = False
-
-    def _setItem(self, item, attribute):
-
-        if self._item is not None and self._item is not item:
-            raise ValueError, 'item attribute value %s is already owned by another item %s' %(self, self._item)
-        
-        self._item = item
-        if self._dirty:
-            item.setDirty()
-
-        self._attribute = attribute
-
-    def _getItem(self):
-
-        return self._item
-
-    def _getAttribute(self):
-
-        return self._attribute
-
-    def _setDirty(self):
-
-        if not self._dirty:
-            self._dirty = True
-            if self._item is not None:
-                self._item.setDirty(attribute=self._attribute,
-                                    dirty=Item.VDIRTY)
-
-    def _copy(self, item, attribute):
-
-        raise NotImplementedError, 'ItemValue._copy is abstract'

Index: osaf/chandler/Chandler/repository/item/PersistentCollections.py
diff -u osaf/chandler/Chandler/repository/item/PersistentCollections.py:1.9 osaf/chandler/Chandler/repository/item/PersistentCollections.py:1.10
--- osaf/chandler/Chandler/repository/item/PersistentCollections.py:1.9	Fri Mar 26 16:39:24 2004
+++ osaf/chandler/Chandler/repository/item/PersistentCollections.py	Wed Mar 31 13:24:19 2004
@@ -1,11 +1,12 @@
 
-__revision__  = "$Revision: 1.9 $"
-__date__      = "$Date: 2004/03/27 00:39:24 $"
+__revision__  = "$Revision: 1.10 $"
+__date__      = "$Date: 2004/03/31 21:24:19 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
 
 import repository.item.Item
+import repository.item.Values 
 
 from repository.util.UUID import UUID
 from repository.util.SingleRef import SingleRef
@@ -46,7 +47,7 @@
         for value in self.itervalues():
             if isinstance(value, PersistentCollection):
                 value._setItem(item, attribute, companion)
-            elif isinstance(value, repository.item.Item.ItemValue):
+            elif isinstance(value, repository.item.Values.ItemValue):
                 value._setItem(item, attribute)
 
     def __setItem(self, item, attribute, companion):
@@ -74,7 +75,7 @@
                                    self._companion, **value)
         elif isinstance(value, repository.item.Item.Item):
             value = SingleRef(value._uuid)
-        elif isinstance(value, repository.item.Item.ItemValue):
+        elif isinstance(value, repository.item.Values.ItemValue):
             value._setItem(self._item, self._attribute)
 
         return value

Index: osaf/chandler/Chandler/repository/item/ItemHandler.py
diff -u osaf/chandler/Chandler/repository/item/ItemHandler.py:1.33 osaf/chandler/Chandler/repository/item/ItemHandler.py:1.34
--- osaf/chandler/Chandler/repository/item/ItemHandler.py:1.33	Fri Mar 26 11:25:48 2004
+++ osaf/chandler/Chandler/repository/item/ItemHandler.py	Wed Mar 31 13:24:19 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.33 $"
-__date__      = "$Date: 2004/03/26 19:25:48 $"
+__revision__  = "$Revision: 1.34 $"
+__date__      = "$Date: 2004/03/31 21:24:19 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -9,7 +9,8 @@
 from repository.item.PersistentCollections import PersistentCollection
 from repository.item.PersistentCollections import PersistentList
 from repository.item.PersistentCollections import PersistentDict
-from repository.item.ItemRef import Values, References, RefArgs, NoneRef
+from repository.item.ItemRef import RefArgs, NoneRef
+from repository.item.Values import Values, References, ItemValue
 
 from repository.util.SingleRef import SingleRef
 from repository.util.UUID import UUID
@@ -168,7 +169,7 @@
                 companion = item.getAttributeAspect(attribute, 'companion',
                                                     default=None)
                 value._setItem(item, attribute, companion)
-            elif isinstance(value, ItemPackage.Item.ItemValue):
+            elif isinstance(value, ItemValue):
                 value._setItem(item, attribute)
 
         for refArgs in self.refs:

Index: osaf/chandler/Chandler/repository/persistence/XMLRepositoryView.py
diff -u osaf/chandler/Chandler/repository/persistence/XMLRepositoryView.py:1.31 osaf/chandler/Chandler/repository/persistence/XMLRepositoryView.py:1.32
--- osaf/chandler/Chandler/repository/persistence/XMLRepositoryView.py:1.31	Tue Mar 23 21:08:47 2004
+++ osaf/chandler/Chandler/repository/persistence/XMLRepositoryView.py	Wed Mar 31 13:24:26 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.31 $"
-__date__      = "$Date: 2004/03/24 05:08:47 $"
+__revision__  = "$Revision: 1.32 $"
+__date__      = "$Date: 2004/03/31 21:24:26 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -13,8 +13,9 @@
 from bsddb.db import DB_DIRTY_READ, DB_LOCK_WRITE
 from dbxml import XmlDocument, XmlValue
 
-from repository.item.Item import Item, ItemValue
-from repository.item.ItemRef import RefDict, TransientRefDict, Values
+from repository.item.Item import Item
+from repository.item.Values import Values, ItemValue
+from repository.item.ItemRef import RefDict, TransientRefDict
 from repository.persistence.Repository import Repository, RepositoryError
 from repository.persistence.Repository import VersionConflictError
 from repository.persistence.Repository import OnDemandRepositoryView
@@ -575,7 +576,6 @@
         self._uuid = None
         self._view = view
         self._version = 0
-        self._indexed = False
 
     def _xmlValue(self, generator):
 

Index: osaf/chandler/Chandler/repository/schema/Kind.py
diff -u osaf/chandler/Chandler/repository/schema/Kind.py:1.60 osaf/chandler/Chandler/repository/schema/Kind.py:1.61
--- osaf/chandler/Chandler/repository/schema/Kind.py:1.60	Fri Mar 26 16:39:25 2004
+++ osaf/chandler/Chandler/repository/schema/Kind.py	Wed Mar 31 13:24:28 2004
@@ -1,11 +1,12 @@
 
-__revision__  = "$Revision: 1.60 $"
-__date__      = "$Date: 2004/03/27 00:39:25 $"
+__revision__  = "$Revision: 1.61 $"
+__date__      = "$Date: 2004/03/31 21:24:28 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
 
-from repository.item.Item import Item, ItemValue
+from repository.item.Item import Item
+from repository.item.Values import ItemValue
 from repository.item.ItemRef import ItemRef, RefDict, NoneRef
 from repository.item.PersistentCollections import PersistentCollection
 from repository.util.Path import Path

Index: osaf/chandler/Chandler/repository/parcel/tests/.cvsignore
diff -u osaf/chandler/Chandler/repository/parcel/tests/.cvsignore:1.1 osaf/chandler/Chandler/repository/parcel/tests/.cvsignore:1.2
--- osaf/chandler/Chandler/repository/parcel/tests/.cvsignore:1.1	Sun Feb 15 18:52:56 2004
+++ osaf/chandler/Chandler/repository/parcel/tests/.cvsignore	Wed Mar 31 13:24:20 2004
@@ -1,2 +1,3 @@
 *.pyo
 *.pyc
+__repository__



More information about the Commits mailing list