Nick Chong
Nick Chong

Reputation: 13

How to transfer message between different request in web.py?

In web.py, I use web.seeother() to redirect to another page, is there a way to transfer some message to that page too?

Upvotes: 0

Views: 589

Answers (2)

Felix-Herve
Felix-Herve

Reputation: 26

You can pass globals to the template engine and link it to your session:

session = web.session.Session(app,web.session.DiskStore('sessions'), initializer={'message': ""})
render = web.template.render('templates/', globals={'context': session}, base='layout')

inside your template:

$if context.message:
  <div id="messageBox">
  $context.message
  </div>

Something like that.

Upvotes: 1

heinzderaugust
heinzderaugust

Reputation: 11

you can use a Get Variable: web.seeother('/somepage?message=hello')

bye

Upvotes: 0

Related Questions