[Zope-CMF] Re: Small CMFCatalogAware refactoring

Jean-Marc Orliaguet jmo at ita.chalmers.se
Mon Sep 12 09:17:54 EDT 2005


Tres Seaver wrote:

> Jean-Marc Orliaguet wrote:
>
> >then there is a list of hooks that can be migrated to the new
> >getToolByName() when it materializes. At least this shows the need for
> >named utilities in CMF.
>
>
> Those won't be named utilities;  they will be adapters, with
> "tool-centric" interfaces.  For code which currently spells the lookup::
>
>   catalog = getToolByName(some_context, 'portal_catalog')
>
> I prefer::
>
>   catalog = ICatalog(some_context)
>
> rather than::
>
>   catalog = getUtility(IGenericTool, 'portal_catalog')
>
> which will permit us to do component-style indirections based on the
> type of 'some_context'.
>
>
> Tres.
> --
>

Ah OK, Julien's fix aimed at fixing the following use case:

some object types (that follow a document management logic) are indexed
in 'portal_catalog', others that follow a page presentation logic (e.g.
portlets) are stored in a separate catalog.

portlets are CMFCatalogAware and subclass
CMFCatalogAware._getCatalogTool(), so this is much closer an approach to
the adapter-like tool lookup that you are describing than the
getToolByName() described by Sidnei. The only difference is that
adapters don't exist in Zope2 so subclassing is used instead, but
Julien's idea was more or less the same.

/JM


More information about the Zope-CMF mailing list