Why we want to have _actionSet() method in class Page?

Class Page(HTTPServlet):

  (...)

     def _respond(self, transaction):
       req = transaction.request()

if self.transaction().application().setting('OldStyleActions', ) \
and req.hasField('_action_'):
(*) action = self.methodNameForAction(req.field('_action_'))
actions = self._actionSet()
(*) if actions.has_key(action):
self.preAction(action)
apply(getattr(self, action), (transaction,))
self.postAction(action)
return
else:
raise PageError, "Action '%s' is not in the public list of actions, %s, for %s." % (action, actions.keys(), self)


       for action in self.actions():
         if req.hasField('_action_%s' % action) or \
            req.field('_action_', None) == action or \
            (req.hasField('_action_%s.x' % action) and \
            req.hasField('_action_%s.y' % action)):
(**)           if self._actionSet().has_key(action):
                self.handleAction(action)
                return

     def _actionSet(self):
       if not hasattr(self, '_actionDict'):
         self._actionDict = {}
         for action in self.actions():
(***)       self._actionDict[action] = 1
       return self._actionDict

     def handleAction(self, action):
       self.preAction(action)
       getattr(self, action)()
       self.postAction(action)

     def methodNameForAction(self, name):
       return name


I think condition in line marked with (**) is needless as self.actionSet().key() are always equal to self.actions(). In my opinion there should be one more condition in line (***) to make it sense:


(***) if getattr(self, action, None):
self._actionDict[action] = 1



Consider lines marked with (*). Can it work correctly, if self.methodNameForAction(name) returns with something other then name?


Another questions: It is intentional not to call methodNameForAction() in code for new style actions? And is it correct to handle new style action if user want old one?

I can prepare patches (for class Page form Webware and from WSGIKit and for class CPage from Components) but I need to know answers for last to questions.

Regards

--
Radosław Kintzi (radek at lucasconsulting dot pl)



-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
_______________________________________________
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel

Reply via email to