[Zope-dev] Question: additional context for IAnnotations adapter?

Jacob Holm jh at improva.dk
Thu Mar 5 19:55:38 EST 2009


Hi Dan

Dan Korostelev wrote:
> Hi there!
>
> While looking at the zope.app.principalannotation package, I
> discovered that both zope.annotation and zope.app.principalannotation
> register their IAnnotations adapters twice: fisrt, as a simple adapter
> and second, as a multi adapter for some additional context object.
>
> The zope.annotation doesn't use that additional context at all - it
> just allows to get annnotations by multi-adapter lookup. The
> zope.app.principalannotation uses the additional context object as
> context argument for getSiteManager, which I believe is not needed
> and/or used in most cases, because application components, like
> zope.site provide their hooks to get the right site manager.
>
> There's no documentation or any tests for that behaviour neither in
> zope.app.principalannotation, nor in zope.annotation, so I made an
> assumption that these registrations are there just to support some
> very old annotation pattern, that was deprecated ages ago. If it's
> like that, I'd like to remove that registration for
> zope.principalannotation that is about to born as well as for
> zope.annotation.
>
> Can someone clarify this point?
>   
I added it while working for ZC two years ago. It was needed to support 
a use case where the context used for looking up the annotation was not 
necessarily the current site. I don't know if the use case is still 
relevant to ZC, but the pattern is still being used in e.g. 
zc.notification and zope.app.preference (where it was added by me at the 
time). In both cases it is important that the annotations are looked up 
in some context rather than in whatever the current site happens to be.

Hope this helps

Jacob



More information about the Zope-Dev mailing list