comparison 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
comparison
equal deleted inserted replaced
2902:f50b867747c9 2903:2681cfbd0fcb
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 $
2 2
3 """WWW request handler (also used in the stand-alone server). 3 """WWW request handler (also used in the stand-alone server).
4 """ 4 """
5 __docformat__ = 'restructuredtext' 5 __docformat__ = 'restructuredtext'
6 6
639 except: 639 except:
640 # everything else 640 # everything else
641 return cgitb.pt_html(i18n=self.translator) 641 return cgitb.pt_html(i18n=self.translator)
642 642
643 # these are the actions that are available 643 # these are the actions that are available
644 actions = ( 644 actions = {
645 ('edit', EditItemAction), 645 'edit': EditItemAction,
646 ('editcsv', EditCSVAction), 646 'editcsv': EditCSVAction,
647 ('new', NewItemAction), 647 'new': NewItemAction,
648 ('register', RegisterAction), 648 'register': RegisterAction,
649 ('confrego', ConfRegoAction), 649 'confrego': ConfRegoAction,
650 ('passrst', PassResetAction), 650 'passrst': PassResetAction,
651 ('login', LoginAction), 651 'login': LoginAction,
652 ('logout', LogoutAction), 652 'logout': LogoutAction,
653 ('search', SearchAction), 653 'search': SearchAction,
654 ('retire', RetireAction), 654 'retire': RetireAction,
655 ('show', ShowAction), 655 'show': ShowAction,
656 ('export_csv', ExportCSVAction), 656 'export_csv': ExportCSVAction,
657 ) 657 }
658 def handle_action(self): 658 def handle_action(self):
659 ''' Determine whether there should be an Action called. 659 ''' Determine whether there should be an Action called.
660 660
661 The action is defined by the form variable :action which 661 The action is defined by the form variable :action which
662 identifies the method on this object to call. The actions 662 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.
664 664
665 Actions may return a page (by default HTML) to return to the 665 Actions may return a page (by default HTML) to return to the
666 user, bypassing the usual template rendering. 666 user, bypassing the usual template rendering.
667 ''' 667 '''
668 if self.form.has_key(':action'): 668 if self.form.has_key(':action'):
676 if (hasattr(self.instance, 'cgi_actions') and 676 if (hasattr(self.instance, 'cgi_actions') and
677 self.instance.cgi_actions.has_key(action)): 677 self.instance.cgi_actions.has_key(action)):
678 # tracker-defined action 678 # tracker-defined action
679 action_klass = self.instance.cgi_actions[action] 679 action_klass = self.instance.cgi_actions[action]
680 else: 680 else:
681 # go with a default 681 if isinstance(self.actions, type({})):
682 for name, action_klass in self.actions: 682 if not self.actions.has_key(action):
683 if name == action: 683 raise ValueError, 'No such action "%s"'%action
684 break 684 action_class = self.actions[action]
685 else: 685 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
687 692
688 # call the mapped action 693 # call the mapped action
689 if isinstance(action_klass, type('')): 694 if isinstance(action_klass, type('')):
690 # old way of specifying actions 695 # old way of specifying actions
691 return getattr(self, action_klass)() 696 return getattr(self, action_klass)()

Roundup Issue Tracker: http://roundup-tracker.org/