While reading identity.conditions, I noticed this in
not_anonymous.eval_with_object.
Shouldn't line 108 be :
108 if identity.anonymous:
?
The 1.0 branch contains the following :
103 class not_anonymous(Predicate, IdentityPredicateHelper):
104 """Predicate for checking whether current visitor is anonymous."""
105 error_message = "Anonymous access denied"
106
107 def eval_with_object(self, identity, errors=None):
108 if current.anonymous:
109 self.append_error_message(errors)
110 return False
111 return True
I'm just curious.
Regards,
Christophe
No, I think current.anonymous is correct; "current" is the identity
wrapper. Maybe you were confused because it's named "identity" in the
template std vars.
-- Christoph
The thing is that in the other predicates, "identity" is used. Note
that in this context "identity" is the parameter of the function, not
the identity module.
So my understanding is that the predicate shouldn't access the global
"current" identity but the one given as a parameter.
Christophe
Yes, this is an inconsistency in the code which I also noticed earlier
but didn't have the time to correct. Can you file a bug ticket, please?
It doesn't matter when you use the standard identity decorator, but it
might lead to subtle bugs when customizing the identity predicates.
Chris
Done, with a patch for branch 1.0.
http://trac.turbogears.org/ticket/2029
The 1.1 branch is not concerned.
Regards,
Christophe
Ah, sorry, now I see what you mean. It actually amounts to the same,
since "not_anonymous" is intended to be used by the "require" decorator
which always passes "current" as the "identity" parameter. But you're
right, this should at least be handled consistently in all predicates.
-- Christoph