[Grok-dev] Annotations Usage Pattern

Wichert Akkerman wichert at wiggy.net
Mon Jun 8 05:22:13 EDT 2009


On 6/5/09 7:29 PM, Steve Schmechel wrote:
> --- On Fri, 6/5/09, Wichert Akkerman<wichert at wiggy.net>  wrote:
>
>    
>> From: Wichert Akkerman<wichert at wiggy.net>
>> Subject: Re: [Grok-dev] Annotations Usage Pattern
>> To: "Paul Wilson"<paulalexwilson at gmail.com>
>> Cc: "Grok"<grok-dev at zope.org>
>> Date: Friday, June 5, 2009, 8:53 AM
>> Previously Paul Wilson wrote:
>>      
>>> Hi Grokkers,
>>>
>>> I'm writing a system that uses annotations to store
>>>        
>> metadata about my
>>      
>>> objects. I'm using the annotations concept as a way of
>>>        
>> providing an
>>      
>>> extensible metadata facility. However as I continue to
>>>        
>> read and learn about
>>      
>>> Zope/Grok - I'm not sure about whether I'm taking the
>>>        
>> right approach.
>>      
>>> Looking at code/commentries written by a prominent
>>>        
>> Grok/Zope member, they
>>      
>>> advocate only non-extensive usage of annotations, and
>>>        
>> in their code write a
>>      
>>> meta-data facility which uses containment rather than
>>>        
>> annotations to solve
>>      
>>> the problem.
>>>
>>> What wisdom on this topic do you have?
>>>        
>> It depends a bit on your application. Annotations are very
>> convenient,
>> but they have one downside: annotations are not stored
>> directly on
>> the object being annotated but in a BTree on that object.
>> That means
>> they are not in the same ZODB object. So instead of loading
>> one object
>> from the ZODB you might need to load several objects, which
>> will
>> increase latency and cache pressure. Most of the time that
>> is not
>> problematic. If you need to scale up to large or high
>> performance
>> systems this can become an important factor.
>>
>> A rule of thumb: data that is accessed often should be
>> stored in the
>> ZODB object, for example via an attribute on the python
>> object.
>>      
>
> So, to clarify the rule against some examples I was considering:
>
> If I have several types of content objects for which I want to add a "comment" feature, and the comments will generally be viewed every time the content objected is viewed, placing the collection of comments on an attribute of the content object would be the way to go.
>    

Yes.

> If I want to record the history of work-flow state for various content objects, but only authors and administrators might view this information occasionally, then a collection of that history objects as an annotation on the content object would be more appropriate.
>    

Correct.

> Am I understanding this correctly?
>    

Indeed you are!

Wichert.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20090608/9a06f8d9/attachment.html 


More information about the Grok-dev mailing list