[Zope-CMF] small proposal, catalog tool
computing project
computer-project at hotmail.co.uk
Fri Aug 19 19:03:52 EDT 2005
Hi,
I'd like to change the way that the catalog is implemented slightly, to
allow tools other than the workflow tool to provide variables to the
catalog. I'm happy to submit the code + tests if everyone's
happy/interested.
1. Provide a new interface. Currently, only the workflow tool implements
this interface
class ICatalogVariableProvider(Interface):
def getCatalogVariablesFor(obj):
"""Return a dictionary of additional properties to be made available to
the catalog when an object is indexed
"""
return vars
2. Change the catalog tool to something like:
def catalog_object(self, obj, uid, idxs=None, update_metadata=1):
vars = {}
for tool in self._providers:
pt = getToolByName(obj, tool, None)
if pt:
vars.update( pt.getCatalogVariablesFor( obj ) )
w = IndexableObjectWrapper(vars, obj)
ZCatalog.catalog_object(self, w, uid, idxs, update_metadata)
where at the moment, _providers would be just a one-item tuple (
'portal_workflow', )
This way it's much easier to hook other tools in at indexing time by adding
them to the list, rather than needing to create a new catalog class. (note
this code is a rough cut-and-paste, so it might well have typos - for
illustration only!)
Any thoughts? Is this useful?
pete
_________________________________________________________________
Use MSN Messenger to send music and pics to your friends
http://messenger.msn.co.uk
More information about the Zope-CMF
mailing list