[Zope] Re: ATFolder Annotations on Plone, could not find adapter on Windows

Radim Novotny novotny.radim at gmail.com
Fri May 11 07:49:50 EDT 2007


IIRC, you must explicitly include annotation package in your configure.zcml:

  <include package="zope.app.annotation" />

> Hi:
> 
> I have Plone 2.5.2 installed on Zope 2.9.5 in two different machines.
> The first one is my Ubuntu box and the other one is a Windows server.
> 
> I've created a custom content-type that basically inherits from ATFolder
> (Products.ATContentTypes.content.folder.ATFolder). After our zope3
> training at Chappel Hill with Phillip, I'm trying to do my developments
> in a "Zope3-style", so I decided to store some data as an annotation of
> this objects.
> 
> So, I mark my class with IAttributeAnnotatable, and when I try to adapt
> my object to IAnnotations to get or set the annotations, it works on my
> Linux but not on Windows.
> 
> If I go to the ZMI and check this object's Interfaces tab
> (www.myserver.com/myobject/manage_interfaces), I can see that
> IAttributeAnnotatable is in the interface list of the object, but Zope
> fails to find the adapter.
> 
> I've added a pdb.set_trace() in my annotation accessing view, and
> debugged it using runzope.bat but I'm still getting 'Could not adapt'
> error. I paste the debugging session:
> 
> (Pdb) l
>  80    def __call__(self, *args, **kwargs):
>  81        context = aq_inner(self.context)
>  82        import pdb; pdb.set_trace()
>  83        try:
>  84            adapted = IAnnotations(context)
>  85        except:
>  86            from zope.app.annotation.interfaces import
> IAttributeAnnotatable
>  87            data = IAttributeAnnotatable.providedBy(context)
>  88            return str(data)
>  89
>  90        return adapted.get(self.ANNOTATION_KEY, '')
> (Pdb) context
> <MUSubSite at /mu/subgep>
> (Pdb) from zope.app.annotation.interfaces import IAttributeAnnotatable as ii
> (Pdb) from zope.app.annotation.interfaces import IAnnotations
> (Pdb) ii.providedBy(context)
> True
> (Pdb) IAnnotations(context)
> *** Type Error: ('Could not adapt', <MUSubSite at /mu/subgep>,
> <InterfaceClass zope.app.annotation.interfaces.IAnnotations>)
> (Pdb)
> 
> Firstly, I thought that perhaps there was some nasty Acquisition issue
> here, so I tried with self.context (without the aq_inner thing), but it
> also fails:
> 
> (Pdb) ii.providedBy(self.context)
> True
> (Pdb) IAnnotations(self.context)
> *** Type Error: ('Could not adapt', <MUSubSite at /mu/subgep>,
> <InterfaceClass zope.app.annotation.interfaces.IAnnotations>)
> (Pdb)
> 
> In my Linux box, everything works great:
> 
> (Pdb) context
> <MUSubSite at /mu/eps>
> (Pdb) self.context
> <MUSubSite at /mu/eps>
> (Pdb) from zope.app.annotation.interfaces import IAnnotations
> (Pdb) from zope.app.annotation.interfaces import IAttributeAnnotatable as ii
> (Pdb) ii.providedBy(context)
> True
> (Pdb) ii.providedBy(self.context)
> True
> (Pdb) IAnnotations(context)
> {}
> (Pdb) IAnnotations(self.context)
> {}
> 
> Any hint will be appreciated,
> 
> Best regards,
> 
> Mikel Larreategi
> 
> 

-- 
naro



More information about the Zope mailing list