[Zope3-dev] Store information to principals

Kapil Thangavelu hazmat at objectrealms.net
Sat Aug 21 12:34:48 EDT 2004


On Aug 21, 2004, at 11:40 AM, Florian Lindner wrote:

> Am Samstag, 21. August 2004 16:05 schrieben Sie:
>> On Aug 21, 2004, at 9:27 AM, Florian Lindner wrote:
>>> 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.
>
> Ok, that's exactly what I want to. Is there any detailed introduction  
> around
> to the PrincipalAnnotation Service in the Internet.

not really. you can see some general information on annotations here  
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/ 
Zope3Book/annotations.html  the type of annotation covered there,  
namely service stored annotations is exactly the same thing the  
principal annotation service is doing.

also, while the zope3 book does a great job of getting developers  
started, zope3 is not ready imho for those who aren't willing to dig  
into the source.

>
>>>>> 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?
>>
>> the zope3 security model is similiar to zope2 afaics, principals map  
>> to
>> roles, and roles map to permissions. permissions guard access to
>> attributes, including those to create other principals (although from
>> the code it looks like you can grant principals permissions directly
>> but its not exposed through the ui) . so if you setup a principal auth
>> service, and a principal source within it you can then add new
>> principals ttw. then to selectively give the ability to create
>> principals to to others users you would grant them the appropriate  
>> role
>> with the appropriate permission (for example "Manage Principals").
>
> I think you misunderstood me. I didn't meant the creation of new  
> principals
> but only to collect principals in groups.
> Every user and create a arbitrary number of groups containing other
> principals. Something like a ICQ user can create user groups. The  
> prinicipals
> in the user groups shouldn't be real users, only pointers to real  
> users.
>

i did misunderstand,  so it sounds more like you want a collection of  
principles as a content object more than as a security entity, in which  
case, maybe creating a containerish content class that holds a  
principal reference objects with an adapter defined to the actual  
princple for canonical resolution of some attributes (like name, email,  
etc) that would be stored in principle annotations, but would also  
allow for per user markup of the principles in their groups.


>>>>> 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?
>>
>> yes
>>
>>> What is type annotations?
>>
>> its a mapping.
>>
>>> How do I need to register this component with ZCML?
>>
>> the annotation stuff is built in, afaics.
>
> But where to put this piece of code? And how to tell Zope where I've  
> put it?

you could use it your views of the principals.

>
>>> How to create a Webinterface for the ZMI to change the annotations?
>>> With
>>> schema like ContentObjects?
>>
>> i dunno..  i suppose it would depend on the application.. perhaps just
>> map some views onto a containment based principal source and its
>> principals.
>
> Thanks for your help....
> I hope I'm not acting to stupid....  ;-)
> Florian
>

no worries, i'm learning z3 stuff as well, and hoping that others will  
correct me if i'm mistaken ;-)

cheers,

-kapil



More information about the Zope3-dev mailing list