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
80def __call__(self, *args, **kwargs):
81context = aq_inner(self.context)
82import pdb; pdb.set_trace()
83try:
84adapted = IAnnotations(context)
85except:
86from zope.app.annotation.interfaces import
IAttributeAnnotatable
87data = IAttributeAnnotatable.providedBy(context)
88return str(data)
89
90return 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
--
Mikel Larreategi
[EMAIL PROTECTED]
CodeSyntax
Azitaingo Industrialdea 3 K
E-20600 Eibar
Tel: (+34) 943 82 17 80
___
Zope maillist - Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )