[Zope] Managing local roles with a script
Etienne Labuschagne
ELabuschane@gmsonline.co.za
Wed, 13 Nov 2002 10:30:19 +0200
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C28AEE.E68B8CF0
Content-Type: text/plain;
charset="iso-8859-1"
After playing around last night, I found a hackish workaround for my
problem. Instead of trying to delete the user's local roles, I just assign
a bogus role (eg. "Dummy") to the user in that folder. This replaces the
"Broker" role and removes the user's accreditation for that product. I'd
still appreciate it if someone can enlighten me on why the below does not
work.
Etienne
-----Original Message-----
From: Etienne Labuschagne [mailto:ELabuschane@gmsonline.co.za]
Sent: Tuesday, November 12, 2002 8:26 PM
To: 'zope@zope.org'
Subject: [Zope] Managing local roles with a script
I have a CMF site. In the site there are three folders, A, B and C which I
call products. To view a product you need the "Broker" role.
I want to be able to "accredit" a user for any combination of product A, B
and C. Thus I wrote a script, assigning the local Role "Broker" to a user
for the folder A, B or C (according to his accreditation).
This works fine.
I also want to be able to remove the accreditation. So I wrote a script
that removes the local roles for those accreditations that were removed.
My problem is with the removing. The script has proxy role Manager, Broker
(and just about anything else by now!) but I cannot get it to remove the
roles.
In the script I have tried:
productFolder.manage_delLocalRoles([userId])
AND
context.portal_membership.deleteLocalRoles(productFolder, [userId])
Out of the source I understand why the latter doesn't work - it ignores
proxy roles and uses manage_delLocalRoles anyway. Why doesn't the first one
also not work? Does it also ignore proxy roles? The script works if I am
logged in as "Manager", but I want a "BrokerManager" user to also be able to
use this script without giving him full "Manager" rights.
B.t.w. the above fails silently, no exception, the role removal just doesn't
happen.
Thanks
Etienne
------_=_NextPart_001_01C28AEE.E68B8CF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [Zope] Managing local roles with a script</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2>After playing around last night, I found a hackish =
workaround for my problem. Instead of trying to delete the user's =
local roles, I just assign a bogus role (eg. "Dummy") to the =
user in that folder. This replaces the "Broker" role and =
removes the user's accreditation for that product. I'd still =
appreciate it if someone can enlighten me on why the below does not =
work.</FONT></P>
<P><FONT SIZE=3D2>Etienne</FONT>
</P>
<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Etienne Labuschagne [<A =
HREF=3D"mailto:ELabuschane@gmsonline.co.za">mailto:ELabuschane@gmsonline=
.co.za</A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Tuesday, November 12, 2002 8:26 PM</FONT>
<BR><FONT SIZE=3D2>To: 'zope@zope.org'</FONT>
<BR><FONT SIZE=3D2>Subject: [Zope] Managing local roles with a =
script</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>I have a CMF site. In the site there are three =
folders, A, B and C which I call products. To view a product you =
need the "Broker" role.</FONT></P>
<P><FONT SIZE=3D2>I want to be able to "accredit" a user for =
any combination of product A, B and C. Thus I wrote a script, =
assigning the local Role "Broker" to a user for the folder A, =
B or C (according to his accreditation).</FONT></P>
<P><FONT SIZE=3D2>This works fine. </FONT>
<BR><FONT SIZE=3D2>I also want to be able to remove the =
accreditation. So I wrote a script that removes the local roles =
for those accreditations that were removed.</FONT></P>
<P><FONT SIZE=3D2>My problem is with the removing. The script has =
proxy role Manager, Broker (and just about anything else by now!) but I =
cannot get it to remove the roles.</FONT></P>
<P><FONT SIZE=3D2>In the script I have tried: </FONT>
<BR><FONT SIZE=3D2>productFolder.manage_delLocalRoles([userId]) </FONT>
<BR><FONT SIZE=3D2>AND </FONT>
<BR><FONT =
SIZE=3D2>context.portal_membership.deleteLocalRoles(productFolder, =
[userId]) </FONT>
<BR><FONT SIZE=3D2>Out of the source I understand why the latter =
doesn't work - it ignores proxy roles and uses manage_delLocalRoles =
anyway. Why doesn't the first one also not work? Does it =
also ignore proxy roles? The script works if I am logged in as =
"Manager", but I want a "BrokerManager" user to =
also be able to use this script without giving him full =
"Manager" rights.</FONT></P>
<P><FONT SIZE=3D2>B.t.w. the above fails silently, no exception, the =
role removal just doesn't happen. </FONT>
<BR><FONT SIZE=3D2>Thanks </FONT>
<BR><FONT SIZE=3D2>Etienne </FONT>
</P>
</BODY>
</HTML>
------_=_NextPart_001_01C28AEE.E68B8CF0--