Hello,
I'm currently writting a product which is a small extension to
CPSDocument, and wishes to make its instances accessible/viewable by
anonymous users.
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 ?
* does this indicate a bug of some sort ?
* is there another simple, straightforward way to programmatically set
the permissions on an arbitrary Zope object ?
Thanks,
Aurélien.
_______________________________________________
cps-users mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/cps-users