[Zope3-dev] Store information to principals

Florian Lindner mailinglists at xgm.de
Sat Aug 21 09:27:16 EDT 2004


Am Samstag, 21. August 2004 08:21 schrieben Sie:
> 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

Ok, thats what I thought.

> > Can it be done through a web interface?
>
> you'd have to make one, zope3 is very much python developer oriented at
> this stage.

Ok.

> >  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 don't really understand how want to do that with permission. Can you explain 
a little detailed?

> > 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

What type is zapi.getService returning? I have't found in the apidoc. Is it a 
zope.app.principalannotation.interfaces.IPrincipalAnnotationService?
What is type annotations?

How do I need to register this component with ZCML?
How to create a Webinterface for the ZMI to change the annotations? With 
schema like ContentObjects?

Thx,
Florian



More information about the Zope3-dev mailing list