[Zope-Checkins]
SVN: Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/
- simplified implementation
Andreas Jung
andreas at andreas-jung.com
Thu Jul 15 11:23:42 EDT 2004
Log message for revision 26554:
- simplified implementation
- renamed handlers
- added zlog handler
Changed:
U Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/ProgressHandler.py
U Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/ZCatalog.py
-=-
Modified: Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/ProgressHandler.py
===================================================================
--- Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/ProgressHandler.py 2004-07-15 15:22:19 UTC (rev 26553)
+++ Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/ProgressHandler.py 2004-07-15 15:23:42 UTC (rev 26554)
@@ -16,8 +16,9 @@
"""
import time, sys
+from zLOG import LOG, INFO
-class DefaultProgressHandler:
+class StdoutHandler:
""" A simple progress handler """
def __init__(self, steps=100):
@@ -42,25 +43,9 @@
print >>self.fp, '%s: %s' % (self._ident, text)
-class ProgressMixin:
- """ A simple machinery to provide progres informations for long running
- ZCatalog operations like reindexing.
- """
+class ZLogHandler(StdoutHandler):
+ """ Use zLOG """
- def pg_register(self, handler=None):
- self._v_pg_handler = handler
+ def output(self, text):
+ LOG(self._ident, INFO, text)
- def pg_init(self, ident, max):
- handler = getattr(self, '_v_pg_handler', None)
- if not handler: return
- handler.init(ident, max)
-
- def pg_finish(self):
- handler = getattr(self, '_v_pg_handler', None)
- if not handler: return
- handler.finish()
-
- def pg_report(self, current, *args, **kw):
- handler = getattr(self, '_v_pg_handler', None)
- if not handler: return
- handler.report(current, *args, **kw)
Modified: Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/ZCatalog.py
===================================================================
--- Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/ZCatalog.py 2004-07-15 15:22:19 UTC (rev 26553)
+++ Zope/branches/ajung-zcatalog-progress/lib/python/Products/ZCatalog/ZCatalog.py 2004-07-15 15:23:42 UTC (rev 26554)
@@ -38,7 +38,6 @@
import urllib, time, sys
import string,logging
from IZCatalog import IZCatalog
-from ProgressHandler import ProgressMixin, DefaultProgressHandler
LOG = logging.getLogger('Zope.ZCatalog')
@@ -57,7 +56,7 @@
return self.manage_main(self, REQUEST,update_menu=1)
-class ZCatalog(Folder, Persistent, Implicit, ProgressMixin):
+class ZCatalog(Folder, Persistent, Implicit):
"""ZCatalog object
A ZCatalog contains arbirary index like references to Zope
@@ -461,7 +460,7 @@
'/manage_catalogIndexes?manage_tabs_message=Index%20Cleared')
- def reindexIndex(self, name, REQUEST):
+ def reindexIndex(self, name, REQUEST, pghandler=None):
if isinstance(name, str):
name = (name,)
@@ -469,12 +468,13 @@
num_paths = len(paths) # inefficient
i = 0
- self.pg_register(DefaultProgressHandler(steps=10))
- self.pg_init('reindexing %s' % name, num_paths)
+ if pghandler:
+ pghandler.init('reindexing %s' % name, num_paths)
for p in paths:
i+=1
- self.pg_report(i)
+ if pghandler: pghandler.report(i)
+
obj = self.resolve_path(p)
if not obj:
obj = self.resolve_url(p, REQUEST)
@@ -498,7 +498,8 @@
DeprecationWarning)
self.catalog_object(obj, p, idxs=name)
- self.pg_finish()
+ if pghandler:
+ pghandler.finish()
def manage_reindexIndex(self, ids=None, REQUEST=None, RESPONSE=None,
URL1=None):
More information about the Zope-Checkins
mailing list