1- # $Id: client.py,v 1.33 2002-09-15 22:41:15 richard Exp $
1+ # $Id: client.py,v 1.34 2002-09-16 05:32:09 richard Exp $
22
33__doc__ = """
44WWW request handler (also used in the stand-alone server).
@@ -344,8 +344,8 @@ def renderTemplate(self, name, extension, **kwargs):
344344 # let the template render figure stuff out
345345 return pt .render (self , None , None , ** kwargs )
346346 except PageTemplate .PTRuntimeError , message :
347- return '<strong>%s</strong><ol>%s</ol>' % (message ,
348- '<li>' .join (pt ._v_errors ))
347+ return '<strong>%s</strong><ol><li> %s</ol>' % (message ,
348+ '<li>' .join ([ cgi . escape ( x ) for x in pt ._v_errors ] ))
349349 except NoTemplate , message :
350350 return '<strong>%s</strong>' % message
351351 except :
@@ -369,21 +369,21 @@ def content(self):
369369 return self .renderTemplate (self .classname , self .template )
370370
371371 # these are the actions that are available
372- actions = {
373- 'edit' : 'editItemAction' ,
374- 'editCSV' : 'editCSVAction' ,
375- 'new' : 'newItemAction' ,
376- 'register' : 'registerAction' ,
377- 'login' : 'loginAction' ,
378- 'logout' : 'logout_action' ,
379- 'search' : 'searchAction' ,
380- }
372+ actions = (
373+ ( 'edit' , 'editItemAction' ) ,
374+ ( 'editCSV' , 'editCSVAction' ) ,
375+ ( 'new' , 'newItemAction' ) ,
376+ ( 'register' , 'registerAction' ) ,
377+ ( 'login' , 'loginAction' ) ,
378+ ( 'logout' , 'logout_action' ) ,
379+ ( 'search' , 'searchAction' ) ,
380+ )
381381 def handle_action (self ):
382382 ''' Determine whether there should be an _action called.
383383
384384 The action is defined by the form variable :action which
385385 identifies the method on this object to call. The four basic
386- actions are defined in the "actions" dictionary on this class:
386+ actions are defined in the "actions" sequence on this class:
387387 "edit" -> self.editItemAction
388388 "new" -> self.newItemAction
389389 "register" -> self.registerAction
@@ -397,11 +397,14 @@ def handle_action(self):
397397 try :
398398 # get the action, validate it
399399 action = self .form [':action' ].value
400- if not self .actions .has_key (action ):
400+ for name , method in selc .actions :
401+ if name == action :
402+ break
403+ else :
401404 raise ValueError , 'No such action "%s"' % action
402405
403406 # call the mapped action
404- getattr (self , self . actions [ action ] )()
407+ getattr (self , method )()
405408 except Redirect :
406409 raise
407410 except Unauthorised :
0 commit comments