Anthony's response suggests a better way to solve your problem yet I
can see people wanting to forward headers. This is possible.

   redirect(URL(...))

is the same as

   raise HTTP(303,location=URL(...))

the named arguments of HTTP are headers so you can do:

   raise HTTP(303,location=URL(...),success=True)

or (forward all headers)

   raise HTTP(303,location=URL(...),**request.headers)



On Nov 28, 7:15 am, thodoris <[email protected]> wrote:
> I want to do the following:
>
> I want to add a key to response.headers
>
> response.headers['success']='True'
>
> after a successful file upload and also redirect.
>
> The problem is that i also want to redirect after successful upload
> but redirect makes a new reasponse.headers and i lose the key i want
> to add.
>
> Is there a way to solve this?
>
> When upload fails and i don't get redirected i can see my key in the
> headers.
>
> My code is:
>
> @auth.requires_login()
> def upload():
>     db.reactable.id.default = request.args(0)
>     form=SQLFORM(db.table)
>     response.headers['success']='False'
>     if form.accepts(request.vars,session):
>         response.headers['success']='True'
>         session.flash="Record added"
>         redirect(URL('index'))
>     return dict(form=form)

Reply via email to