RE: [Zope] testing for local roles
Well, while we're on the subject of AUTHENTICATED_USER.has_role, I've just come upon an error that just popped up all of a sudden in an SQL query that was working fine before. The problematic line is:
<dtml-if "AUTHENTICATED_USER.has_role('Manager',this())">
and the error I get when trying to test it is:
Error, exceptions.NameError: AUTHENTICATED_USER
<snip>
Another query in the same folder uses the exact same if statement, and works fine. I am running 2.2b4. Can anyone suggest a solution?
Aaron - Are you passing AUTHENTICATED_USER as an argument to the query that is working (and not doing so on this one?) Remember that SQL methods don't automagically get the same namespace that DTML does - the only things it can use are attributes that are named in the arguments list (this is to prevent names that are coincidentally the same in a REQUEST form or something from being inserted into queries). One common way of doing what you want is to add REQUEST to the arguments list of the SQLMethod and use: <dtml-with REQUEST> <dtml-if "AUTHENTICATED_USER.has_role('Manager',this())"> select * from data </dtml-if> </dtml-with> Brian Lloyd brian@digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com
participants (1)
-
Brian Lloyd