[Zope-dev] Question: additional context for IAnnotations adapter?
Jacob Holm
jh at improva.dk
Fri Mar 13 06:36:54 EDT 2009
Chris Withers wrote:
> [snip]
> It's interesting, this use case sound pretty close to what I'm talking
> about in the very last part of this message:
>
> http://mail.zope.org/pipermail/zope-dev/2009-March/035220.html
>
> ie: adapter context based on object traversal rather than notion of
> "current site".
>
Not quite, since this was about principal annotations and principals
cannot be found by object traversal. It was specifically about letting
the adapter know the context, not about finding a different adapter
based on context.
> Can someone confirm to me whether or not manually specifying the context
> as I have in the example above would work, or would I need to do:
>
> >>> adapter1 = getAdapter(a,ISomething,context=siteA)
> >>> adapter2 = getAdapter(b,ISomething,context=siteB)
>
In general, using "context=a" should give the same result as
"context=siteA".
In the particular case of principalannotations, this would not help.
There the adapter is the same globally, but needs to know the context so
it can find the proper utility to use. To make it work you'd need to
register a different adapter for each utility. This is certainly doable,
but probably not worth the effort.
Hope this helps
Jacob
More information about the Zope-Dev
mailing list