Skip to content

Commit 8204cd0

Browse files
author
Richard Jones
committed
factor out get_action_class so it may be called from other places
1 parent 869727f commit 8204cd0

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

roundup/cgi/client.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.208 2004-11-22 10:46:18 a1s Exp $
1+
# $Id: client.py,v 1.209 2004-11-23 22:44:43 richard Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -158,6 +158,9 @@ def __init__(self, instance, request, env, form=None, translator=None):
158158

159159
self.user = None
160160
self.userid = None
161+
self.nodeid = None
162+
self.classname = None
163+
self.template = None
161164

162165
def setTranslator(self, translator=None):
163166
"""Replace the translation engine
@@ -401,7 +404,7 @@ def determine_user(self):
401404
pass
402405
username, password = decoded.split(':')
403406
try:
404-
LoginAction(self).verifyLogin(username, password)
407+
self.get_action_class('login')(self).verifyLogin(username, password)
405408
except LoginError, err:
406409
self.make_user_anonymous()
407410
self.response_code = 403
@@ -732,17 +735,7 @@ def handle_action(self):
732735
return None
733736

734737
try:
735-
if (hasattr(self.instance, 'cgi_actions') and
736-
self.instance.cgi_actions.has_key(action)):
737-
# tracker-defined action
738-
action_klass = self.instance.cgi_actions[action]
739-
else:
740-
# go with a default
741-
for name, action_klass in self.actions:
742-
if name == action:
743-
break
744-
else:
745-
raise ValueError, 'No such action "%s"'%action
738+
action_klass = self.get_action_class(action)
746739

747740
# call the mapped action
748741
if isinstance(action_klass, type('')):
@@ -754,6 +747,20 @@ def handle_action(self):
754747
except ValueError, err:
755748
self.error_message.append(str(err))
756749

750+
def get_action_class(self, action_name):
751+
if (hasattr(self.instance, 'cgi_actions') and
752+
self.instance.cgi_actions.has_key(action_name)):
753+
# tracker-defined action
754+
action_klass = self.instance.cgi_actions[action_name]
755+
else:
756+
# go with a default
757+
for name, action_klass in self.actions:
758+
if name == action_name:
759+
break
760+
else:
761+
raise ValueError, 'No such action "%s"'%action_name
762+
return action_klass
763+
757764
def write(self, content):
758765
if not self.headers_done:
759766
self.header()

0 commit comments

Comments
 (0)