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?


Use MSN Messenger to send music and pics to your friends http://messenger.msn.co.uk

Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to