redirect_to

0 views
Skip to first unread message

Antipin Aleksei

unread,
May 12, 2007, 11:39:46 AM5/12/07
to pylons-...@googlegroups.com
Hi

Is there simple way to pass "c" to redirected page? For instance I set
c.errorMsg, run redirect_to and show c.errorMsg in that page.

--
Best regards,
Antipin Aleksei

Max Ischenko

unread,
May 12, 2007, 12:39:36 PM5/12/07
to pylons-...@googlegroups.com
Hi,

On 5/12/07, Antipin Aleksei <antipin...@gmail.com> wrote:
Is there simple way to pass "c" to redirected page? For instance I set
c.errorMsg, run redirect_to and show c.errorMsg in that page.

Turbogears does this with cookies  (see tg.flash() implementation). You can do roughly the same with Pylons but this functionality is not built-in (yet). Search this ML archives, there were some code snippets .

Max.


__wyatt

unread,
May 12, 2007, 9:03:54 PM5/12/07
to pylons-discuss
On May 12, 8:39 am, Antipin Aleksei <antipin.alek...@gmail.com> wrote:
> Hi
>
> Is there simple way to pass "c" to redirected page? For instance I set
> c.errorMsg, run redirect_to and show c.errorMsg in that page.

You can do something like this:

# somewhere in a controller/action:
session['errors'] = 'Unknown region: %s' % region_id
session.save()
redirect_to('/regions', **dict(params))

# in the controller/action you redirected to:
if 'errors' in session:
c.title = 'Error'
c.errors = session.pop('errors')
session.save() # gotta do this to actually remove 'errors'
from the session

You can see this in context here:

http://trac.bycycle.org/browser/apps/web/tripplanner/trunk/tripplanner/controllers/regions.py


HTH,

__wyatt

Reply all
Reply to author
Forward
0 new messages