Pregunta

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

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top