[python script] problem with AUTHENTICATED_USER
I have problem with my python script. I want to check if a user has a the "manager" role, and add an option in a menu in this case Here is my script: for el in rep.objectValues('Folder'): if el.id=="Administration" and AUTHENTICATED_USER.has_role(self, ["Manager"]): #add option to the menu but Zope displays me an error: Error Type: NameError Error Value: global name 'AUTHENTICATED_USER' is not defined I don't know what is the problem. I use sessionUserFolder (a Zope products), so I think it could be the reason of the problem. Thank you for your help
hi: AUTHENTICATED_USER is in REQUEST: hence you could write ... self.REQUEST.AUTHENTICATED_USER.has_role(self, ["Manager"]) ... regards, juergen herrmann [ BonviciniJ@keops.net wrote:]
I have problem with my python script. I want to check if a user has a the "manager" role, and add an option in a menu in this case Here is my script:
for el in rep.objectValues('Folder'): if el.id=="Administration" and AUTHENTICATED_USER.has_role(self, ["Manager"]): #add option to the menu
but Zope displays me an error: Error Type: NameError Error Value: global name 'AUTHENTICATED_USER' is not defined
I don't know what is the problem. I use sessionUserFolder (a Zope products), so I think it could be the reason of the problem. Thank you for your help
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________________________________
XLhost.de - eXperts in Linux hosting <<
Juergen Herrmann Weiherweg 10, 93051 Regensburg, Germany Fon: +49 (0)700 XLHOSTDE [0700 95467833] Fax: +49 (0)721 151 463027 ICQ: 27139974 - IRC: #XLhost@quakenet WEB: http://www.XLhost.de
Jürgen Herrmann wrote:
hi:
AUTHENTICATED_USER is in REQUEST:
hence you could write ... self.REQUEST.AUTHENTICATED_USER.has_role(self, ["Manager"]) ...
Yes, but this is deprecated. Do what Andreas said :-) cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
--On Mittwoch, 20. April 2005 16:30 Uhr +0200 BonviciniJ@keops.net wrote:
I have problem with my python script. I want to check if a user has a the "manager" role, and add an option in a menu in this case Here is my script:
for el in rep.objectValues('Folder'): if el.id=="Administration" and AUTHENTICATED_USER.has_role(self, ["Manager"]): #add option to the menu
The recommended way to determine the current user is: from AccessControl import getSecurityManager() user = getSecurityManager().getUser() -aj
participants (4)
-
Andreas Jung -
BonviciniJ@keops.net -
Chris Withers -
Jürgen Herrmann