[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog - Catalog.py:1.74.8.1 Lazy.py:1.4.40.1 ZCatalog.py:1.92.6.1
Shane Hathaway
shane@digicool.com
Thu, 9 Aug 2001 13:34:10 -0400
Update of /cvs-repository/Zope/lib/python/Products/ZCatalog
In directory cvs.zope.org:/tmp/cvs-serv29115/lib/python/Products/ZCatalog
Modified Files:
Tag: NR-branch
Catalog.py Lazy.py ZCatalog.py
Log Message:
Sync NR-branch with trunk. Sorry about so many checkin messages...
=== Zope/lib/python/Products/ZCatalog/Catalog.py 1.74 => 1.74.8.1 ===
- def reindexIndex(self,name):
-
- for p in self.paths.items():
- print p
-
# the cataloging API
def catalogObject(self, object, uid, threshold=None,idxs=[]):
@@ -560,6 +555,7 @@
else:
try:
for k, intset in sort_index.items():
+ if hasattr(intset, 'keys'): intset=intset.keys()
append((k,LazyMap(self.__getitem__, intset)))
except AttributeError:
raise ValueError, (
@@ -664,7 +660,7 @@
if sort_index is None: r=r[0]
else: r=r[0][1]
else:
- if sort_index is None: r=LazyCat(r)
+ if sort_index is None: r=LazyCat(r, len(r))
else:
r.sort()
if kw.has_key('sort-order'):
@@ -677,7 +673,7 @@
if (type(so) is type('') and
lower(so) in ('reverse', 'descending')):
r.reverse()
- r=LazyCat(map(lambda i: i[1], r))
+ r=LazyCat(map(lambda i: i[1], r), len(r))
return r
=== Zope/lib/python/Products/ZCatalog/Lazy.py 1.4 => 1.4.40.1 ===
def __getslice__(self,i1,i2):
r=[]
- for i in range(i1,i2):
+ for i in xrange(i1,i2):
try: r.append(self[i])
except IndexError: return r
return r
=== Zope/lib/python/Products/ZCatalog/ZCatalog.py 1.92 => 1.92.6.1 ===
('Manage ZCatalog Entries',
['manage_catalogObject', 'manage_uncatalogObject',
- 'catalog_object', 'uncatalog_object',
+ 'catalog_object', 'uncatalog_object', 'refreshCatalog',
'manage_catalogView', 'manage_catalogFind',
'manage_catalogSchema', 'manage_catalogIndexes',
@@ -323,16 +323,8 @@
elapse = time.time()
c_elapse = time.clock()
-
- paths = tuple(self._catalog.paths.values())
- self._catalog.clear()
- for p in paths:
- obj = self.resolve_path(p)
- if not obj:
- obj = self.resolve_url(p, REQUEST)
- if obj is not None:
- self.catalog_object(obj, p)
+ self.refreshCatalog(clear=1)
elapse = time.time() - elapse
c_elapse = time.clock() - c_elapse
@@ -344,8 +336,24 @@
'Total CPU time: %s' % (`elapse`, `c_elapse`)))
+ def refreshCatalog(self, clear=0):
+ """ re-index everything we can find """
+
+ cat = self._catalog
+ paths = cat.paths.values()
+ if clear:
+ paths = tuple(paths)
+ cat.clear()
+
+ for p in paths:
+ obj = self.resolve_path(p)
+ if not obj:
+ obj = self.resolve_url(p, self.REQUEST)
+ if obj is not None:
+ self.catalog_object(obj, p)
+
def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None):
- """ clears the whole enchelada """
+ """ clears the whole enchilada """
self._catalog.clear()
if REQUEST and RESPONSE:
@@ -794,6 +802,7 @@
def addIndex(self, name, type,extra=None):
+
# Convert the type by finding an appropriate product which supports
# this interface by that name. Bleah
@@ -815,7 +824,16 @@
if base is None:
raise ValueError, "Index type %s does not support addIndex" % type
- index = base(name, self)
+ # This code is somewhat lame but every index type has its own function
+ # signature *sigh* and there is no common way to pass additional parameters
+ # to the constructor. The suggested way for new index types is to use
+ # an "extra" record.
+
+ if 'extra' in base.__init__.func_code.co_varnames:
+ index = apply(base,(name,), {"extra":extra,"caller":self})
+ else:
+ index = base(name,self)
+
self._catalog.addIndex(name,index)