[Checkins] SVN: lovely.tag/trunk/src/lovely/tag/ fix/change for using IOSets instead of sets

Manfred Schwendinger manfred.schwendiger at lovelysystems.com
Mon Feb 12 10:16:19 EST 2007


Log message for revision 72502:
  fix/change for using IOSets instead of sets

Changed:
  U   lovely.tag/trunk/src/lovely/tag/engine.py
  U   lovely.tag/trunk/src/lovely/tag/generations/__init__.py
  A   lovely.tag/trunk/src/lovely/tag/generations/evolve1.py

-=-
Modified: lovely.tag/trunk/src/lovely/tag/engine.py
===================================================================
--- lovely.tag/trunk/src/lovely/tag/engine.py	2007-02-12 14:07:41 UTC (rev 72501)
+++ lovely.tag/trunk/src/lovely/tag/engine.py	2007-02-12 15:14:10 UTC (rev 72502)
@@ -22,6 +22,7 @@
 import zope.interface
 from zope import component
 from BTrees import IOBTree, OOBTree
+
 from zope.app.container import contained
 from zope.app import intid
 from zope.app.intid.interfaces import IIntIdRemovedEvent, IIntIds
@@ -198,10 +199,14 @@
             result = tags_result
         else:
             result = tags_result.intersection(users_result)
+        res = set()
+        for uid in result:
+            o = self._tag_ids.queryObject(uid)
+            if o is not None:
+                res.add(o.item)
+        return res
 
-        return set([self._tag_ids.getObject(id).item for id in result])
 
-
     def getUsers(self, tags=None, items=None):
         """See interfaces.ITaggingEngine"""
         if tags is None and items is None:
@@ -301,7 +306,7 @@
         for tagId in tagIds:
             tagObj = self._tag_ids.getObject(tagId)
             tagObj.name = new
-        newTagIds = set(self._name_to_tagids.get(new, ()))
+        newTagIds = IOBTree.IOSet(self._name_to_tagids.get(new, ()))
         newTagIds.update(tagIds)
         self._name_to_tagids[new] = newTagIds
         del self._name_to_tagids[old]

Modified: lovely.tag/trunk/src/lovely/tag/generations/__init__.py
===================================================================
--- lovely.tag/trunk/src/lovely/tag/generations/__init__.py	2007-02-12 14:07:41 UTC (rev 72501)
+++ lovely.tag/trunk/src/lovely/tag/generations/__init__.py	2007-02-12 15:14:10 UTC (rev 72502)
@@ -14,6 +14,6 @@
 
 
 schemaManager = SchemaManager(
-    minimum_generation=0,
-    generation=0,
+    minimum_generation=1,
+    generation=1,
     package_name=pkg)

Added: lovely.tag/trunk/src/lovely/tag/generations/evolve1.py
===================================================================
--- lovely.tag/trunk/src/lovely/tag/generations/evolve1.py	2007-02-12 14:07:41 UTC (rev 72501)
+++ lovely.tag/trunk/src/lovely/tag/generations/evolve1.py	2007-02-12 15:14:10 UTC (rev 72502)
@@ -0,0 +1,23 @@
+from zope.app.zopeappgenerations import getRootFolder
+from zope.app.generations.utility import findObjectsProviding
+from lovely.tag.interfaces import ITaggingEngine
+from pytz import UTC
+from BTrees import IOBTree
+from zope.app.component.interfaces import ISite
+def evolve(context):
+    """evolve to use -IOSet- instead of -set- instances"""
+
+    for s in findObjectsProviding(getRootFolder(context), ISite):
+        for engine in s.getSiteManager().getAllUtilitiesRegisteredFor(
+            ITaggingEngine):
+            print u'engine found'
+            for key, val in engine._name_to_tagids.items():
+                changed = False
+                for uid in list(val):
+                    if engine._tag_ids.queryObject(uid) is None:
+                        changed=True
+                        val.remove(uid)
+                if changed or not isinstance(val, IOBTree.IOSet):
+                    engine._name_to_tagids[key] = IOBTree.IOSet(val)
+
+                


Property changes on: lovely.tag/trunk/src/lovely/tag/generations/evolve1.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native



More information about the Checkins mailing list