Frage

class LeaveFormHandler(BaseHandler):
  def post(self):
    #form submission code goes here
      #after this code i wanted to call post method of MyleavesHandler class

class MyleavesHandler(BaseHandler):
  def post(self):
        self.write(json.dumps(r))

after the form submission code in the above snippet, i wanted to call post method of MyleavesHandler class.. can anyone please help am a newbie

iam using tornado webserver with python

War es hilfreich?

Lösung

You can't call instance methods of another handler because you can't easily construct one, and even if you could, you need to ultimately call self.write() on the LeaveFormHandler, not the MyleavesHandler. You need to factor the logic you want to share out into a shareable location, either a common base class or a static function that takes a handler as an argument.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top