1- # $Id: client.py,v 1.197 2004-11-08 23:29:45 richard Exp $
1+ # $Id: client.py,v 1.198 2004-11-11 21:10:05 richard Exp $
22
33"""WWW request handler (also used in the stand-alone server).
44"""
@@ -641,26 +641,26 @@ def renderContext(self):
641641 return cgitb .pt_html (i18n = self .translator )
642642
643643 # these are the actions that are available
644- actions = (
645- ( 'edit' , EditItemAction ) ,
646- ( 'editcsv' , EditCSVAction ) ,
647- ( 'new' , NewItemAction ) ,
648- ( 'register' , RegisterAction ) ,
649- ( 'confrego' , ConfRegoAction ) ,
650- ( 'passrst' , PassResetAction ) ,
651- ( 'login' , LoginAction ) ,
652- ( 'logout' , LogoutAction ) ,
653- ( 'search' , SearchAction ) ,
654- ( 'retire' , RetireAction ) ,
655- ( 'show' , ShowAction ) ,
656- ( 'export_csv' , ExportCSVAction ) ,
657- )
644+ actions = {
645+ 'edit' : EditItemAction ,
646+ 'editcsv' : EditCSVAction ,
647+ 'new' : NewItemAction ,
648+ 'register' : RegisterAction ,
649+ 'confrego' : ConfRegoAction ,
650+ 'passrst' : PassResetAction ,
651+ 'login' : LoginAction ,
652+ 'logout' : LogoutAction ,
653+ 'search' : SearchAction ,
654+ 'retire' : RetireAction ,
655+ 'show' : ShowAction ,
656+ 'export_csv' : ExportCSVAction ,
657+ }
658658 def handle_action (self ):
659659 ''' Determine whether there should be an Action called.
660660
661661 The action is defined by the form variable :action which
662662 identifies the method on this object to call. The actions
663- are defined in the "actions" sequence on this class.
663+ are defined in the "actions" dictionary on this class.
664664
665665 Actions may return a page (by default HTML) to return to the
666666 user, bypassing the usual template rendering.
@@ -678,12 +678,17 @@ def handle_action(self):
678678 # tracker-defined action
679679 action_klass = self .instance .cgi_actions [action ]
680680 else :
681- # go with a default
682- for name , action_klass in self .actions :
683- if name == action :
684- break
681+ if isinstance ( self . actions , type ({})):
682+ if not self .actions . has_key ( action ) :
683+ raise ValueError , 'No such action "%s"' % action
684+ action_class = self . actions [ action ]
685685 else :
686- raise ValueError , 'No such action "%s"' % action
686+ # backwards-compatible sequence
687+ for name , action_klass in self .actions :
688+ if name == action :
689+ break
690+ else :
691+ raise ValueError , 'No such action "%s"' % action
687692
688693 # call the mapped action
689694 if isinstance (action_klass , type ('' )):
0 commit comments