Prokes
Prokes

Reputation: 73

Python Webapp2 call Handler function from within separate Handler

Python 2.7, webapp2, Jinja2

I am trying to call a Handler function from within another Handler with the end goal of rendering a Landing page with a passed argument. Previously, I used self.redirect(/landing) but now need to pass arguments.

Simplified example:

class Landing(Handler):

    def render_index(self, error = ""):
       self.render("index.html", error=error)

    def get(self):
       self.render index()


class Login(Handler):

    def post(self):
       try:
           verify_user()
       except:
           # self.redirect('/landing')
           error = "error message" 
        -> # would like to render Landing page and pass error argument

I am not sure how to do this - any advice is appreciated.

Upvotes: 0

Views: 498

Answers (1)

Mihail Russu
Mihail Russu

Reputation: 2536

Is Landing.get(Landing(request=self.request)) what you are looking for?

Upvotes: 2

Related Questions