[Zope3-Users] New annotations factory problems

Tom Dossis td at yoma.com.au
Wed May 24 17:00:45 EDT 2006


Ron Bickers wrote:
> On Wed May 24 2006 16:42, Tom Dossis wrote:
> 
>> I haven't been following this thread, however from the error message it
>> appears your adapter is missing the context (adaptee)...
>>
>>       def __init__(self, context):
>>          # context is the IItem object to be adapted.
> 
> The README says the following:
> 
> "Note that the annotation implementation does not expect any arguments
> to its `__init__`. Otherwise it's basically an adapter."
> 
> And the example is defined as follows:
> 
> class Bar(Persistent):
>     interface.implements(IBar)
>     component.adapts(IFoo)
>     def __init__(self):
>         self.a = 1
>         self.b = 2
> 
> That's why I didn't think the adapter directive would do the right thing, but 
> all of this (Zope 3) is pretty new to me, so what do I know.

Mmm, I hadn't seen this before.

  >>> from zope.annotation import factory
  >>> component.provideAdapter(factory(Bar))

Did you try something like... ?

  MyFactory=factory(ItemMiscInfo)

And corresponding zcml..

  <adapter
     factory=".mymodule.MyFactory"



More information about the Zope3-users mailing list