[Zope-dev] Zope.principalannotation bug report

Christopher Lozinski lozinski at freerecruiting.com
Mon Jun 9 21:29:14 CEST 2014


Here is an extract from the principalannotation configure.zcml file.

    <adapter factory=".utility.annotations" />

   <adapter
       for="zope.security.interfaces.IPrincipal *"
       factory=".utility.annotations"
       />

Clearly something is wrong.  Two copies, and no "provides" line.

So I tried fixing it.

   <adapter
       factory=".utility.annotations"
       provides="zope.annotation.interfaces.IAnnotations"
       for="zope.principalregistry.principalregistry.Principal"
       />

No luck.  I still get the following error report.  Cannot adapt.

   File 
"/root/.buildout/eggs/zope.app.container-3.9.2-py2.7.egg/zope/app/container/browser/contents.py", 
line 462, in getPrincipalClipboard
     annotations = IAnnotations(user)
TypeError: ('Could not adapt', 
<zope.principalregistry.principalregistry.Principal object at 
0x80bae03d0>, <InterfaceClass zope.annotation.interfaces.IAnnotations>)

I am running the most recent release of grok, to which I added

zope.principalannotation.


I am trying to adapt the user object.
(Pdb) user
<zope.principalregistry.principalregistry.Principal object at 0x80bae03d0>


Here is what I have tried so far.

Maybe I am not installing it correctly. So I inserted a typo in the 
principalannotation configuration file, and sure enough I got an error 
report


So let me see if the adapter is loaded.


(Pdb) from zope.component import getGlobalSiteManager
(Pdb) gsm = getGlobalSiteManager()
(Pdb) gsm.adapters._adapters

A long list is returned, but searching on
zope.annotation.interfaces.IAnnotations
gives me

<implementedBy zope.principalregistry.principalregistry.Principal>: 
{<InterfaceClass zope.annotation.interfaces.IAnnotations\
 >: {u'': <function annotations at 0x80b983230>}},

Okay, so it is in the list of adapters, but getAdapter seems to have a 
problem.


(Pdb)  from zope.component import getAdapter
(Pdb) from zope.annotation.interfaces  import IAnnotations

(Pdb) getAdapter(user,IAnnotations)
*** ComponentLookupError: 
(<zope.principalregistry.principalregistry.Principal object at 
0x80bae03d0>, <InterfaceClass zope.annotation.interfaces.IAnnotations>, u'')


For those interested in the context, I am trying to put up a Zope 2 
style ZMI on top of grok. For the cut copy paste interface, it needs to 
store the objects somewhere, presumably on the principal, but since 
principals are transient objects, the principal annotation package  
stores the data persistently.

I am not sure what to try next.  Any advice would be most appreciated.

Christopher Lozinski





More information about the Zope-Dev mailing list