[Checkins] SVN: zc.relationship/trunk/src/zc/relationship/ bug fix and test

Gary Poster gary at zope.com
Wed Jun 20 19:05:49 EDT 2007


Log message for revision 76869:
  bug fix and test

Changed:
  U   zc.relationship/trunk/src/zc/relationship/README.txt
  U   zc.relationship/trunk/src/zc/relationship/index.py

-=-
Modified: zc.relationship/trunk/src/zc/relationship/README.txt
===================================================================
--- zc.relationship/trunk/src/zc/relationship/README.txt	2007-06-20 22:00:44 UTC (rev 76868)
+++ zc.relationship/trunk/src/zc/relationship/README.txt	2007-06-20 23:05:48 UTC (rev 76869)
@@ -1746,14 +1746,21 @@
     >>> sm['rel_index_3'] = ix
     >>> from BTrees import IFBTree
     >>> app['ex_rel_2'] = rel = Relationship(
-    ...     IFBTree.IFTreeSet((1,)), 'has the role of', IFBTree.IFTreeSet((2,)))
+    ...     IFBTree.IFTreeSet((1,)), 'has the role of', IFBTree.IFTreeSet())
     >>> ix.index(rel)
     >>> list(ix.findValueTokens('objects', {'subjects': 1}))
-    [2]
+    []
+    >>> list(ix.findValueTokens('subjects', {'objects': None}))
+    [1]
 
 Reindexing is where some of the big improvements can happen.  The following
 gyrations exercise the optimization code.
 
+    >>> rel.objects.insert(2)
+    1
+    >>> ix.index(rel)
+    >>> list(ix.findValueTokens('objects', {'subjects': 1}))
+    [2]
     >>> rel.subjects = IFBTree.IFTreeSet((3,4,5))
     >>> ix.index(rel)
     >>> list(ix.findValueTokens('objects', {'subjects': 3}))

Modified: zc.relationship/trunk/src/zc/relationship/index.py
===================================================================
--- zc.relationship/trunk/src/zc/relationship/index.py	2007-06-20 22:00:44 UTC (rev 76868)
+++ zc.relationship/trunk/src/zc/relationship/index.py	2007-06-20 23:05:48 UTC (rev 76869)
@@ -280,8 +280,9 @@
             for data in self._attrs.values():
                 assert self._reltoken_name_TO_objtokenset.get(
                     (relToken, data['name']), self) is self
-                values, tokens, gen = self._getValuesAndTokens(rel, data)
-                if gen:
+                values, tokens, optimization = self._getValuesAndTokens(
+                    rel, data)
+                if optimization and tokens is not None:
                     tokens = data['TreeSet'](tokens)
                 self._add(relToken, tokens, data['name'], tokens)
             self._relTokens.insert(relToken)



More information about the Checkins mailing list