Mercurial > moin > 1.9
changeset 3355:19a7a6efaa21
ActionBase: allow is_allowed() to return a tuple (allowed, message)
author | Johannes Berg <johannes AT sipsolutions DOT net> |
---|---|
date | Thu, 20 Mar 2008 16:20:23 +0100 |
parents | 3f2e51a2dd08 |
children | 2dd4904cfee4 |
files | MoinMoin/action/__init__.py |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/action/__init__.py Thu Mar 20 16:13:54 2008 +0100 +++ b/MoinMoin/action/__init__.py Thu Mar 20 16:20:23 2008 +0100 @@ -64,7 +64,11 @@ return self.actionname in self.cfg.actions_excluded def is_allowed(self): - """ Return True if action is allowed (by ACL) """ + """ + Return True if action is allowed (by ACL), or + return a tuple (allowed, message) to show a + message other than the default. + """ return True def check_condition(self): @@ -183,8 +187,14 @@ error = None if self.is_excluded(): error = _('Action %(actionname)s is excluded in this wiki!') % {'actionname': self.actionname } - elif not self.is_allowed(): - error = _('You are not allowed to use action %(actionname)s on this page!') % {'actionname': self.actionname } + else: + allowed = self.is_allowed() + if isinstance(allowed, tuple): + allowed, msg = allowed + else: + msg = _('You are not allowed to use action %(actionname)s on this page!') % {'actionname': self.actionname } + if not allowed: + error = msg if error is None: error = self.check_condition() if error: