Re: [Zope-CMF] small proposal, catalog tool
computing project wrote at 2005-8-19 23:03 +: >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. I like your proposal. -- Dieter ___ Zope-CMF maillist - [EMAIL PROTECTED] http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
Re: [Zope-CMF] small proposal, catalog tool
On Friday 19 August 2005 04:03 pm, computing project wrote: > 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? In Plone 2.1 we have an ExtensibleIndexableObjectWrapper which allows products to register methods with the catalog for use in indexing and metadata. I think this handles the same (or similar) usecases in a different but potentially more flexible manner. Plone uses it to register all sorts of tool methods, rather than indexing python scripts or something similarly inefficient. Hopefully this might make it into the CMF core at some point. Alec Mitchell ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests
[Zope-CMF] small proposal, catalog tool
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 ___ Zope-CMF maillist - Zope-CMF@lists.zope.org http://mail.zope.org/mailman/listinfo/zope-cmf See http://collector.zope.org/CMF for bug reports and feature requests