[Grok-dev] Problem with Annotations

Souheil CHELFOUH trollfot at gmail.com
Wed Sep 23 09:01:08 EDT 2009

Paul, first of all, i'm glad to learn that you are building a
framework/CMS for Grok
I didn't hear about it and I'm also working on a similar project : Dolmen

About your problem, I'd rather use a namespace traverser as they are
elegant and readable:

But, your metadata issue sounds weird to me
Can you explain in more details ?

2009/9/23 Sebastian Ware <sebastian at urbantalk.se>:
> Personally I would probably have one Annotation class that handles all
> the meta data. I would define a view (orinary or JSON) to access the
> meta data (rather than using traverse).
>   http://server:port/path/to/object/meta_data_view
> For simple meta data you might want to store them in a PersistentDict
> in order to avoid multiple db-lookups. If the meta data is large, you
> will want a BTree-style container (such as grok.Container).
> Mvh Sebastian
> On 23 sep 2009, at 12.15, Paul Wilson wrote:
>> Hi there,
>> I've been having difficulty thinking this one through, any hints
>> appreciated.
>> I'm writing a hobby framework (and content management system) with
>> Grok. The content will have meta-data associated with it. Naturally,
>> I've decided to use annotations to model this meta data. I don't know
>> what meta data will be stored up front; opting instead to allow such a
>> facility to be plugged in. Let's say a have an object called 'foo'
>> that is found at location:
>> http://localhost/container/foo
>> A plugin may, for example, define an IMetaData interface and MetaData
>> annotation that stores the X and Y coordinate of foo. When a client
>> accesses the metadata, it is the interface's schema that is used to
>> deserialise it. So, what I need is some URL format or mechanism that
>> allows me to reference an interface so that I can adapt the content
>> object to it and retrieve the object and then go on to deserialise it.
>> So the first question is, is there some way to look up (in the ZCA) an
>> interface by name? This would allow:
>> http://localhost/container/foo/_metadata
>> I would then go on to define a grok.Traverser that strips the leading
>> slash and looks up the interface.
>> My second question is related. Is there a way to avoid having this
>> naming convention of the leading underscore or similar. Views have @@,
>> and layers have ++Layer++, is there some way of doing something
>> similar in grok to say 'this is not an object, please treat it
>> differently'?
>> Thanks in advance.
>> Regards,
>> Paul
>> _______________________________________________
>> Grok-dev mailing list
>> Grok-dev at zope.org
>> https://mail.zope.org/mailman/listinfo/grok-dev
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev

More information about the Grok-dev mailing list