Zope.principalannotation bug report

Christopher Lozinski <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
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



_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.