-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aurélien Campéas wrote:
> I'm currently writting a product which is a small extension to
> CPSDocument, and wishes to make its instances accessible/viewable by
> anonymous users.
> 

On which class are you adding this and how ? Did you understand the
proxy / repository architecture of CPS ?

Where is located your object (section / workspace) ? Following which
workflow ?

> For this I use a trick used by a collegue : 
> 
>     def set_roles_for_permission(self, permission, role, acquire):
>         """
>         set roles required for a permission on self
>         """
>         from AccessControl.Permission import Permission
>         for p in self.ac_inherited_permissions(1): 
>             name, value = p[:2]
>             if name == permission:
>                 p = Permission(name, value, self)
>                 if acquire:
>                     roles = list(roles)
>                 else:
>                     roles = tuple(roles)
>                 p.setRoles(roles)
>                 return  
>         raise 'Invalid Permission or Roles', \
>         ("The permission <em>%s</em> or roles <em>%s</em> are invalid."
> % (permission,roles))
> 
> (note that I use this code in the "cargo cult" way since I still lack
> knowledge to assess its strengths/weaknesses)
> 
> But this will not work here, for the instances lack the aq_aquire
> attribute needed in the ac_inherited_permissions/_subobject_permissions.
> 
> My question would be :
> 
> * is my collegue recipe plain wrong ?

well, far too complicated to achieve what you wanna do...

> * does this indicate a bug of some sort ?

nope.

> * is there another simple, straightforward way to programmatically set
> the permissions on an arbitrary Zope object ?

Yes, surely.

Did you take a look at CPS local roles on the interface ?

        J.

- --
Julien Anguenot | Nuxeo R&D (Paris, France)
CPS Platform : http://www.cps-project.org
Zope3 / ECM   : http://www.z3lab.org
mail: anguenot at nuxeo.com; tel: +33 (0) 6 72 57 57 66
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDqBHMGhoG8MxZ/pIRAjEjAJ0U8rhcMITo4S4mM/wXXibBac7rgQCfXAhQ
Rzd3gAd5r5Vo1tEWQZiJZx0=
=PiSA
-----END PGP SIGNATURE-----
_______________________________________________
cps-users mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/cps-users

Reply via email to