[Zope] Adding User Roles through Products

Rob Page rob.page@digicool.com
Fri, 21 May 1999 12:36:02 -0400


>  I am developing a product that uses roles to show certain content to
>  different people.
>  I am looking for a way to automatically add new user roles to my
>  products folder in zope when creating a new instance of that product.
>  Is there a way to do that and when how?

<$0.02>
Try calling manage_defined_roles from within the DTML.  Of course, the
calling doc will need a manage proxy role or permissions will break.  I
just checked the online help and manage_defined_roles didn't have great
documentation so you might have to check the docs for necessary
parameters or brute force it by sending a REQUEST.
</$0.02>

** In general, a good way to research these questions is to look in Zope
for what you want to do.  In this case I looked at the Security tab of a
Zope folder, Viewed Source and checked out just what happens when you
add a role.

In this case there is a FORM at the bottom of the Security screen whose
ACTION is manage_defined_roles.  I then took a look at the online help
under Folder and looked for the method manage_defined_roles.  Often
there will be good documentation in the online object reference.  When
there isn't I can grep for manage_defined_roles in the sources to find
out where and how the method is defined...  In this case it turned up
(among other things):

o  access.dtml - controls the look-and-feel of a folder's security tab
o  role.py which contains:

    def manage_defined_roles(self,submit=None,REQUEST=None):

You can, with relatively little pain, read the source there and figure
out what parameters it wants to do what you're after!

The bit of "insider knowledge" that I added was that in order to
call/use a manage* method you need the Manager role.

Hope this helps...

--Rob