[Zope3-dev] Store information to principals
Kapil Thangavelu
hazmat at objectrealms.net
Sat Aug 21 02:21:27 EDT 2004
On Aug 19, 2004, at 12:36 PM, Florian Lindner wrote:
> Hello,
> I want to store further information to principals, like email or
> homepage.
> How can I achieve this in the best way?
using the principal annotation service
> Can it be done through a web interface?
you'd have to make one, zope3 is very much python developer oriented at
this stage.
> What is the PrincipalAnnotation
> Utility doing?
its storing annotations ( transparent property bags) in a
service/utility (the distinction between the two, imho was always
weak.) keyed by the principal id. via the annotations/property bag you
can store arbitrary persistent properties on the annotation like
homepage.
> Or do I need to create a new principal object? (subclass of
> zope.app.services.pluggableauth.SimplePrincipal?)
if you have specialized needs beyond the attribute storage covered
above maybe.
> At a later point a principal should be able to create user groups
> (groups of
> other principals). How would you do that?
give them the appropriate permissions.
>
> I'm not expecting complete implementations here (altough I'd be happy
> about
> it) but I need some information to start (like what Interfaces to
> subclass
> and implement).
untested, but something along the lines of the following might suffice.
from zope.app import zapi
from persistence.dict import PersistentDict
app_namespace = "http://my.example.com/principal_properties"
app_homepage_key = "homepage"
# some class method, where self is context wrapped
def store_homepage( self, principal, homepage ):
annotation_service =
zapi.getService(zapi.servicenames.PrincipalAnnotation, self)
annotations = annotation_service( principal.id )
app_annotations = annotations.setdefault( app_namespace,
PersistentDict)
app_annotations[ app_homepage_key ] = homepage
hth,
Kapil Thangavelu <hazmat at objectrealms.net> Vision Implemented
objectrealms.net <http://www.objectrealms.net>
More information about the Zope3-dev
mailing list