From 2e754503390b97c7f5c399cd32b521be3e4cc05b Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Thu, 12 Jan 2012 12:45:15 -0600 Subject: [PATCH] issue 596, thanks Iceberg --- VERSION | 2 +- gluon/tools.py | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index f6bbb979..8a599fab 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.4 (2012-01-12 12:38:47) stable +Version 1.99.4 (2012-01-12 12:45:12) stable diff --git a/gluon/tools.py b/gluon/tools.py index 81e10482..7a660672 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -2517,16 +2517,11 @@ class Auth(object): self.settings.login_url+\ '?_next='+urllib.quote(next)) - #Check condition variable. - #Since condition could be callable, following cases could occur: - # 1. condition == True => ok - # 2. condition == False => failed - # 3. condition is NOT callable but it NOT None and NOT False and NOT 0 => failed - # 4. condition is callable -> condition() is True => ok - # 5. condition is callable -> condition() is False => failed - # Note: Order is important! At the end condition has to be checked against True - # otherwise case 3 would be ok. - if not (callable(condition) and condition() == True) and not condition == True: + if callable(condition): + flag = condition() + else: + flag = condition + if not flag: current.session.flash = self.messages.access_denied return call_or_redirect( self.settings.on_failed_authorization)