[Product-Developers] Re: Adapters for cataloged objects

Martin Aspeli optilude+lists at gmail.com
Thu Jun 18 18:25:06 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.

That depends on how many objects you're waking up and how big they are. 
It's not always going to be a bad idea.

> Please let me share your better way of dealing with this.

You can either index the value you care about using a custom indexer 
(i.e. you do the adaptation on indexing rather than after your search), 
or wake up the object, or approach your problem differently. :)


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