[Product-Developers] Re: Adapters for cataloged objects

Martin Aspeli optilude+lists at gmail.com
Thu Jun 18 18:27:02 UTC 2009

Taito Horiuchi wrote:
> Hi All,
> Can somebody tell me what is the best practice to adapts adapters to 
> cataloged objects?
> For example, I have ATDocument cataloged as 
> Products.ZCatalog.Catalog.mybrains object.
> I have adapter MyAdapter which adapts ATDocument and provide IMyAdapter.
> To Adapt this cataloged object, I need to wake it up by using 
> getObject() method like:
> IMyAdapter(cataloged_object.getObject())
> Waking up object from zodb is not good practice so, I wonder how you 
> guys do this better.

... and I forgot to add: you can always use a different adapter that 
adapts IZCatalogBrain or whatever it is (see the ZCatalog code) and 
provides your interface. This then needs to be able to do all its work 
with the information on the catalog brain (or wake up the object).

However, you can't get a *different* adapter depending on what the 
underlying object was when it was cataloged. All brains are created equal.


Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

More information about the Product-Developers mailing list