[Plone-Users] AnnotationStorage vs. Attribute storage

14 views
Skip to first unread message

Nico Grubert

unread,
May 25, 2009, 8:05:49 AM5/25/09
to plone...@lists.sourceforge.net
Dear list members

What is the best choice for storage for content types which have:
- some string Fields
- some RichWidget fields
- some DateTime fields
- some ArrayFields
- 1-4 small images (<1 MB)

Example content type:
------------------------------------------------------------------------
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata
from Products.ATContentTypes.content.schemata import finalizeATCTSchema

MyNewsSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

atapi.ImageField('image',
searchable = 0,
required = 0,
max_size = (380, 220),
allowable_content_types = ('image/gif','image/jpeg','image/png'),
widget = atapi.ImageWidget(label = u'Image'),
),

atapi.StringField('image_title',
widget = atapi.StringWidget(label = u'Image title'),
),

atapi.TextField('content',
searchable = 1,
required = 1,
allowable_content_types = ('text/plain',
'text/structured',
'text/html',),
default_output_type = 'text/x-html-safe',
widget = atapi.RichWidget(label = u'Content'),
),

))


finalizeATCTSchema(MyNewsSchema, folderish=True, moveDiscussion=False)

class MyNews(base.ATCTContent):
""" class definitions
"""
------------------------------------------------------------------------

The default storage type is attribute storage. When should I use
AnnotationStorage?
Are there any advantages/disadvantages for both AnnotationStorage and
attribute storage?

Regards
Nico


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
Plone-Users mailing list
Plone...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plone-users

Raphael Ritz

unread,
May 26, 2009, 3:13:45 AM5/26/09
to plone...@lists.sourceforge.net
Nico Grubert wrote:
> Dear list members
>

Hi Nico,

> What is the best choice for storage for content types which have:
> - some string Fields
> - some RichWidget fields
> - some DateTime fields
> - some ArrayFields
> - 1-4 small images (<1 MB)

As a general rule I'd recommend to use AnnotationStorage as
it has a couple of advantages over AttributeStorage: less
chances of name clashes, you can make field values available
as properties (in the Python sense), content objects should
load faster, ...

BUT (there is always a 'but' in life ...)

there are still problems with using AnnotationStorage for
images and files when it comes to traversal to the image
or file object itself. I also don't know whether the
ArrayField's implementation respects Archetypes' storage
abstraction or whether it assumes a certain storage type
at some point.

Also, when it comes to third-party code I've seen more
than once people assuming attribute storage like in

tal:content="here/myfieldname"

instead of

tal:content="here/getMyfieldname"

The former would only be OK if the field value was
made available as a Python property which in turn
requires AnnotationStorage but it sort of works for
AttributeStorage as well but by bypassing the accessor.

So, try for yourself ;-)

Raphael

Reply all
Reply to author
Forward
0 new messages