[Commits] (vajda) - added __contains__, index, count to PersistentList to better support items

commits at osafoundation.org commits at osafoundation.org
Mon Apr 25 17:00:19 PDT 2005


Commit by: vajda
Modified files:
chandler/repository/item/PersistentCollections.py 1.25 1.26

Log message:
   - added __contains__, index, count to PersistentList to better support items


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/PersistentCollections.py.diff?r1=text&tr1=1.25&r2=text&tr2=1.26

Index: chandler/repository/item/PersistentCollections.py
diff -u chandler/repository/item/PersistentCollections.py:1.25 chandler/repository/item/PersistentCollections.py:1.26
--- chandler/repository/item/PersistentCollections.py:1.25	Fri Mar 18 13:41:46 2005
+++ chandler/repository/item/PersistentCollections.py	Mon Apr 25 17:00:18 2005
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.25 $"
-__date__      = "$Date: 2005/03/18 21:41:46 $"
+__revision__  = "$Revision: 1.26 $"
+__date__      = "$Date: 2005/04/26 00:00:18 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -174,6 +174,33 @@
 
         return copy
 
+    def __contains__(self, value):
+
+        from repository.item.Item import Item
+
+        if isinstance(value, Item):
+            value = SingleRef(value._uuid)
+
+        return super(PersistentList, self).__contains__(value)
+
+    def index(self, value):
+
+        from repository.item.Item import Item
+
+        if isinstance(value, Item):
+            value = SingleRef(value._uuid)
+
+        return super(PersistentList, self).index(value)
+
+    def count(self, value):
+
+        from repository.item.Item import Item
+
+        if isinstance(value, Item):
+            value = SingleRef(value._uuid)
+
+        return super(PersistentList, self).count(value)
+
     def __setitem__(self, index, value):
 
         self._storeValue(value)
@@ -238,7 +265,11 @@
 
     def remove(self, value):
 
-        value = self._prepareValue(value)
+        from repository.item.Item import Item
+
+        if isinstance(value, Item):
+            value = SingleRef(value._uuid)
+
         super(PersistentList, self).remove(value)
         self._setDirty()
 



More information about the Commits mailing list