-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alec Mitchell wrote:
> 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.

In a Zope3-centric future, we would probably do this by registering
subscription adapters for some interface, e.g. (notional only)::

  class ICatalogable:
        def items():
            """ Return a sequence of key,value pairs for the context.
            """

and then have the indexing machinery use the component architecture to
find all registered adapters for the indexed object.  The indexes and
metadata would then pull from the mapping created by unioning the items
from the subscription adapters.


Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDBn8C+gerLs4ltQ4RAsrsAJ413J39msbacR8U5bL498qFzIcLawCfWD6A
L6w0mil0s4MUwk179sapvj4=
=agSh
-----END PGP SIGNATURE-----

_______________________________________________
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

Reply via email to