Mercurial > p > roundup > code
diff roundup/cgi/client.py @ 2948:deda13909085
factor out get_action_class so it may be called from other places
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 23 Nov 2004 22:44:43 +0000 |
| parents | e611be5ee6c4 |
| children | 1535b4b5d746 |
line wrap: on
line diff
--- a/roundup/cgi/client.py Mon Nov 22 10:46:18 2004 +0000 +++ b/roundup/cgi/client.py Tue Nov 23 22:44:43 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.208 2004-11-22 10:46:18 a1s Exp $ +# $Id: client.py,v 1.209 2004-11-23 22:44:43 richard Exp $ """WWW request handler (also used in the stand-alone server). """ @@ -158,6 +158,9 @@ self.user = None self.userid = None + self.nodeid = None + self.classname = None + self.template = None def setTranslator(self, translator=None): """Replace the translation engine @@ -401,7 +404,7 @@ pass username, password = decoded.split(':') try: - LoginAction(self).verifyLogin(username, password) + self.get_action_class('login')(self).verifyLogin(username, password) except LoginError, err: self.make_user_anonymous() self.response_code = 403 @@ -732,17 +735,7 @@ return None try: - if (hasattr(self.instance, 'cgi_actions') and - self.instance.cgi_actions.has_key(action)): - # tracker-defined action - action_klass = self.instance.cgi_actions[action] - else: - # go with a default - for name, action_klass in self.actions: - if name == action: - break - else: - raise ValueError, 'No such action "%s"'%action + action_klass = self.get_action_class(action) # call the mapped action if isinstance(action_klass, type('')): @@ -754,6 +747,20 @@ except ValueError, err: self.error_message.append(str(err)) + def get_action_class(self, action_name): + if (hasattr(self.instance, 'cgi_actions') and + self.instance.cgi_actions.has_key(action_name)): + # tracker-defined action + action_klass = self.instance.cgi_actions[action_name] + else: + # go with a default + for name, action_klass in self.actions: + if name == action_name: + break + else: + raise ValueError, 'No such action "%s"'%action_name + return action_klass + def write(self, content): if not self.headers_done: self.header()
