[Product-Developers] Re: paster, AnnotationStorage and the daily cup of ...

Martin Aspeli optilude+lists at gmail.com
Sat Sep 19 10:10:06 UTC 2009


Mikko Ohtamaa wrote:
> Hi,
> 
> Paster archetype template seem to set AnnotationStorage for title and
> description by default.
> 
>     VariantProductSchema['title'].storage = atapi.AnnotationStorage()
>     VariantProductSchema['description'].storage = atapi.AnnotationStorage()
>     
>     schemata.finalizeATCTSchema(
>         VariantProductSchema,
>         folderish=True,
>         moveDiscussion=False
>     )
>     
>     class VariantProduct(folder.ATFolder):
>         """ Buyable physical good with variants of title and price and
> multiple images """
>         implements(IVariantProduct,
>                   Products.PloneGetPaid.interfaces.IShippableMarker)
>     
>         meta_type = "VariantProduct"
>         schema = VariantProductSchema
>     
>         title = atapi.ATFieldProperty('title')
>         description = atapi.ATFieldProperty('description')
> 
> I just checked from AT code and AnnotationStorage uses OOBTree object
> context.__annotations__ as storage backend.
> 
> What I have learnt from Zope world is that objects loaded from OOBTree need
> extra database lookup. This is correct right?
> 
> Because title and description are read almost always when the object is
> being accessed isn't this ineffective? If we open a page for viewing AT
> object created by paster we'd have to do three different database look-ups
> instead of one?
>     
>     Load object
>     Load title for the object from annotations
>     Load description for the object from annoations
>     etc..
> 
> If we used AttributeStorage this would be:
> 
>     Load object (and get title and description on the same fetch)
> 
> Have I understood everything involved here?

You have, although see Andreas' reply. But at the very least, there's 
one more _p_jar to worry about.

I must take the blame for this one. In my book, I do this, because I 
wanted to use an ATFieldProperty for title and description (to allow 
property like access and keep in sync with more Zope 3 like interfaces), 
but you get infinite recursion with AttributeStorage doing that.

At the end of the day, it's all just sugar, but I didn't know at the 
time how it may affect performance.

To be honest, it's probably not a big deal for 99% of people. The main 
problem is that it puts more objects into your ZODB cache and so 
potentially pushes other objects out, even though they're small objects, 
so you can tune your cache accordingly. But it also doesn't really help 
very much. Title() and Description() are more reliable than .title and 
.description anyway.

Martin

-- 
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