[Zope] user roles in standard_error_message

Danny William Adair danny@adair.net
Fri, 11 May 2001 16:36:41 +1200


Hi!

While customizing my standard_error_message, I ran into a little problem: 
Someone with the role "Member" is logged in and tries to access a resource 
that does not exist. Same could happen to someone who doesn't have that 
role (Anonymous). Now I have two different style sheets for members and 
non-members: A member might click on a broken link from within the 
members-only area (having a... pink background), the anonymous user clicked 
the same broken link from a publicly accessible area of the site (having 
a... silver background). I would like to keep the different background 
colors when showing my error message so I put a

<dtml-if "AUTHENTICATED_USER.has_role('Member')">
<dtml-var "members_css">
<dtml-else>
<dtml-var "public_css">
</dtml-if>

in the head section of standard_error_message (these *_css are ZStyleSheets)
My problem is, that it's always the public_css that will show up.

So I checked with

<dtml-var "AUTHENTICATED_USER.getRoles()">

in both the members area and standard_error_message. To my surprise the 
member role was gone:

In the members area getRoles() returned
('Member',)

while in standard_error_message ( _.str(error_type)=='NotFound' ) it returned
('Anonymous',)

btw, the role is not really "lost", I can go back to the members area and 
click through members-only pages without problems.

What's happening?
This looks like buggy, naughty misbehavior :-), doesn't it?

tia,
Danny