[Zope-dev] Getting User Information

Roger Ineichen dev at projekt01.ch
Mon Sep 15 06:34:12 EDT 2008


Hi Rowan

> Betreff: [Zope-dev] Getting User Information
> 
> Hi,
> 
> I'm trying to work out how to get user information from a PAU 
> folder in Zope 3. When a user views or adds a page I either 
> need to lookup the creator or the current user and get their 
> standard information (such as full name, email etc).
> 
> I can see how to do that from the API - getPrincipal(id) - 
> but what I am wondering is how I can find out dynamically how 
> to find out where the PAU is. I guess I should be able to 
> lookup the object using the fact that it has been registered, 
> but I don't know how to do that, nor where to start looking 
> (I've done quite a few google searches).
> 
> Any help/pointers would be much appreciated.

The PAU is a IAuthentication utility with an emtpy string 
as name. You can lookup such an utility with:

import zope.component
from zope.app.security.interfaces import IAuthentication
pau = zope.component.getUtility(IAuthentication)

or you can use queryUtility which returns None 
if not found instead of raise a ComponentLookupError.

If you need to enhance the existing InternalPrincipal
implementation and add some email or phone attributes,
I recommend to take a look at the z3c.authenticator
implementation wich makes that part much simpler.
But note, z3c.authenticator is not compatible
with the zope.app.authentication implementation.

btw, the creator (principal id) will get set by default.
Take a lok at the dublincore implementation.
There is an event subscriber called CreatorAnnotator
which will apply the principal id to each object
if the ObjectCreatedEvent get notified.

See:
zope.dublincore.creatorannotator.CreatorAnnotator

hope that helps

Regards
Roger Ineichen

> Thanks,
> Rowan
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  ** (Related lists -  
> http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope )
> 



More information about the Zope-Dev mailing list