[Grok-dev] Re: Remember who added what

Martijn Faassen faassen at startifact.com
Fri Jun 13 10:57:43 EDT 2008

Hi there,

Peter Bengtsson wrote:
> And by request.principal.id who do I get the User model object
> (...form the PAU presumably)?

No, just the username.

In Zope 3 there can be two user objects in play:

* the principal object. this is a very general object that is used 
internally. This appears on the request if I recall correctly.

* some model that may be stored somewhere. This is an optional object; 
it could be that all your user information is stored somewhere else, 
such as in LDAP, but often in ZODB-backed situations such a user object 

zope.app.authentication only deals with authentication, and doesn't 
actually need to provide a content-space principal abstraction. So a 
principal at minimum only needs to be a unique identifier.

You could however build an authentication system that does store user 
objects in the ZODB on top of that. I believe PrincipalFolder in 
zope.app.authentication helps with that.

Anyway, to conclude (once again):

We need sensible defaults for this and better documentation. It'd be 
nice if I could tell you: "to look up the user object, do this", but 
unfortunately I don't think there is a default way to do that. There's a 
standard way to look up user *ids* based on some query that you can 
support, but user ids don't need to have an object associated with them.

Anyway, to look up who added what comments, the user id is enough, if 
you index the comments by user id using a Field index. This will then 
work no matter how or where your user objects are stored.



More information about the Grok-dev mailing list