[Checkins] SVN: z3c.indexer/trunk/ - Implemented optional intids
argument in SearchQuery.searchResults
Roger Ineichen
roger at projekt01.ch
Mon Aug 4 09:25:50 EDT 2008
Log message for revision 89343:
- Implemented optional intids argument in SearchQuery.searchResults
method. This intids is used instead of query the IntIds util. This is usefull
if you use builtin IIntIds objects for optimized access.
- Added __repr__ for ResultSet with result lenght
- Added tests
- Update CHANGES.txt
Changed:
U z3c.indexer/trunk/CHANGES.txt
U z3c.indexer/trunk/src/z3c/indexer/README.txt
U z3c.indexer/trunk/src/z3c/indexer/interfaces.py
U z3c.indexer/trunk/src/z3c/indexer/search.py
-=-
Modified: z3c.indexer/trunk/CHANGES.txt
===================================================================
--- z3c.indexer/trunk/CHANGES.txt 2008-08-04 10:59:06 UTC (rev 89342)
+++ z3c.indexer/trunk/CHANGES.txt 2008-08-04 13:25:48 UTC (rev 89343)
@@ -20,6 +20,12 @@
empty result if None is given and allow to override existing results as a
part of the SearchQuery API.
+- feature: Implemented optional intids argument in SearchQuery.searchResults
+ method. This intids is used instead of query the IntIds util. This is usefull
+ if you use builtin IIntIds objects for optimized access.
+
+- Added __repr__ for ResultSet with result lenght
+
- Optimized SearchQuery.And() and Not() methods. Skip given query processing
if previous result is empty.
Modified: z3c.indexer/trunk/src/z3c/indexer/README.txt
===================================================================
--- z3c.indexer/trunk/src/z3c/indexer/README.txt 2008-08-04 10:59:06 UTC (rev 89342)
+++ z3c.indexer/trunk/src/z3c/indexer/README.txt 2008-08-04 13:25:48 UTC (rev 89343)
@@ -1018,7 +1018,19 @@
True
+There is an optional intids argument in searchResults. If given, it's used for
+query the objects instead of lookup the IIntIds utility.
+ >>> resultSet = allQuery.searchResults(intids)
+ >>> len(resultSet)
+ 4
+
+This will returnd the same objects as before:
+
+ >>> resultSet[-1:]
+ [<DemoContent u'Apple House Tower'>]
+
+
Batching
--------
Modified: z3c.indexer/trunk/src/z3c/indexer/interfaces.py
===================================================================
--- z3c.indexer/trunk/src/z3c/indexer/interfaces.py 2008-08-04 10:59:06 UTC (rev 89342)
+++ z3c.indexer/trunk/src/z3c/indexer/interfaces.py 2008-08-04 13:25:48 UTC (rev 89343)
@@ -38,8 +38,10 @@
def apply():
"""Return iterable search result wrapper."""
- def searchResults():
- """Retruns iterable search result objects."""
+ def searchResults(intids=None):
+ """Retruns an iterable search result objects. Optional the intids
+ utility can be set for use within the ResulSet implementation.
+ """
def Or(query):
"""Enhance search results. (union)
Modified: z3c.indexer/trunk/src/z3c/indexer/search.py
===================================================================
--- z3c.indexer/trunk/src/z3c/indexer/search.py 2008-08-04 10:59:06 UTC (rev 89342)
+++ z3c.indexer/trunk/src/z3c/indexer/search.py 2008-08-04 13:25:48 UTC (rev 89343)
@@ -56,7 +56,10 @@
obj = self.intids.getObject(uid)
yield obj
+ def __repr__(self):
+ return '<%s len: %s>' %(self.__class__.__name__, len(self.uids))
+
# TODO: allow to initialize with query=None and set the first given query as
# the initial one. If we don't do that, And & Or are never return
# something because of the initial empty IF.Set()
@@ -101,10 +104,11 @@
def apply(self):
return self.results
- def searchResults(self):
+ def searchResults(self, intids=None):
results = []
if len(self.results) > 0:
- intids = zope.component.getUtility(IIntIds)
+ if intids is None:
+ intids = zope.component.getUtility(IIntIds)
results = ResultSet(self.results, intids)
return results
More information about the Checkins
mailing list