Mercurial > p > roundup > code
diff roundup/cgi/client.py @ 2903:2681cfbd0fcb
*** empty log message ***
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 11 Nov 2004 21:10:05 +0000 |
| parents | 0998d1b48182 |
| children | b1ad7add1a2c |
line wrap: on
line diff
--- a/roundup/cgi/client.py Thu Nov 11 12:02:30 2004 +0000 +++ b/roundup/cgi/client.py Thu Nov 11 21:10:05 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.197 2004-11-08 23:29:45 richard Exp $ +# $Id: client.py,v 1.198 2004-11-11 21:10:05 richard Exp $ """WWW request handler (also used in the stand-alone server). """ @@ -641,26 +641,26 @@ return cgitb.pt_html(i18n=self.translator) # these are the actions that are available - actions = ( - ('edit', EditItemAction), - ('editcsv', EditCSVAction), - ('new', NewItemAction), - ('register', RegisterAction), - ('confrego', ConfRegoAction), - ('passrst', PassResetAction), - ('login', LoginAction), - ('logout', LogoutAction), - ('search', SearchAction), - ('retire', RetireAction), - ('show', ShowAction), - ('export_csv', ExportCSVAction), - ) + actions = { + 'edit': EditItemAction, + 'editcsv': EditCSVAction, + 'new': NewItemAction, + 'register': RegisterAction, + 'confrego': ConfRegoAction, + 'passrst': PassResetAction, + 'login': LoginAction, + 'logout': LogoutAction, + 'search': SearchAction, + 'retire': RetireAction, + 'show': ShowAction, + 'export_csv': ExportCSVAction, + } def handle_action(self): ''' Determine whether there should be an Action called. The action is defined by the form variable :action which identifies the method on this object to call. The actions - are defined in the "actions" sequence on this class. + are defined in the "actions" dictionary on this class. Actions may return a page (by default HTML) to return to the user, bypassing the usual template rendering. @@ -678,12 +678,17 @@ # 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 + if isinstance(self.actions, type({})): + if not self.actions.has_key(action): + raise ValueError, 'No such action "%s"'%action + action_class = self.actions[action] else: - raise ValueError, 'No such action "%s"'%action + # backwards-compatible sequence + for name, action_klass in self.actions: + if name == action: + break + else: + raise ValueError, 'No such action "%s"'%action # call the mapped action if isinstance(action_klass, type('')):
