[Zope] Re: forbiddenAttribute, annotation, __call__

Tres Seaver tseaver at palladion.com
Thu Apr 19 11:01:34 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jørgen Jørgensen wrote:
> I'm a little stuck here....
> (And please forgive me, I don't really know what i'm doing)...
> 
> Problem:
> Getting ForbiddenAttribute: ('__call__', on annotation
> 
> I am trying to make a tabbed form which shows
> 'snapin-annotations' as tabs in the same form as the content
> 
> In the form i look up the snapin-adapters like this:
> 
>     def getSnapInAdapters(self):
>         for iface in component.interface.searchInterface(
>             context=None, search_string=None,
>             base=snapin.interfaces.ISnapInAnnotation):
>             myAdapter = component.queryMultiAdapter(
>                 objects=(self.context,), interface=iface, default=None)
>             if myAdapter is None:
>                 continue
>             yield myAdapter
> 
> And then try to adapt the context like this:
> 
>         for myAdapter in self.getSnapInAdapters():
>             snapin=myAdapter(self.context)
> 
> 
> Here I get the error like this:
>     snapin=myAdapter(self.context)
> ForbiddenAttribute: ('__call__', <bdz.testtour.annotation.ContentAnnotationA object at
> 0x03588510>)
> 
> <zcml>
>   <adapter factory="bdz.testtour.annotation.ContentAnnotationA" 
>       trusted="True" 
>       />
> </zcml>
> 
> I must be forgetting something...
> Will You help?

The 'queryMultiAdapter' call has already instantiated the adapter using
'self.context', so you should just be able to use the thing.  E.g.:

        for snapin in self.getSnapInAdapters():
            snaping.doSomethingSnappy()


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGJ4RO+gerLs4ltQ4RAhHkAKCW5srn6gjnn7pHtKIEf/EwUXU2xACcCpXI
OiEbY5xM8HqvW+pRIq+ckl4=
=IQOE
-----END PGP SIGNATURE-----



More information about the Zope mailing list