paster, AnnotationStorage and the daily cup of ...

3 messages Options
Embed this post
Permalink
Mikko Ohtamaa () paster, AnnotationStorage and the daily cup of ...
Reply Threaded More More options
Print post
Permalink
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?
ajung () Re: paster, AnnotationStorage and the daily cup of ...
Reply Threaded More More options
Print post
Permalink
On 19.09.09 10:42, Mikko Ohtamaa wrote:
>
> What I have learnt from Zope world is that objects loaded from OOBTree need
> extra database lookup. This is correct right?
An OOBTree uses buckets as the smallest persistent entity. A bucket usually
holds a small number of items. Buckets are loaded on request and as
needed compared
to using native Python datatypes.

Andreas

[lists.vcf]

begin:vcard
fn:Andreas Jung
n:Jung;Andreas
org:ZOPYX Ltd. & Co. KG
adr;quoted-printable:;;Charlottenstr. 37/1;T=C3=BCbingen;;72070;Germany
email;internet:[hidden email]
title:CEO
tel;work:+49-7071-793376
tel;fax:+49-7071-7936840
tel;home:+49-7071-793257
x-mozilla-html:FALSE
url:www.zopyx.com
version:2.1
end:vcard



_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Martin Aspeli () Re: paster, AnnotationStorage and the daily cup of ...
Reply Threaded More More options
Print post
Permalink
In reply to this post by Mikko Ohtamaa
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


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers