[albatross-users] Changing the status code

Michael C. Neel neel at mediapulse.com
Thu Nov 28 06:10:26 EST 2002


I'm having trouble setting the status of a page though albatross using
mod_python.

I've snipped out extra lines here, but the idea is to set a cookie with
the redirect.  The ctx.request.redirect function ignores any custom
headers, so I had to roll my own here.

in mod_python's handler():

    app = SimpleApp(base_url = '/',
            template_path = '/home/sites/templates',
            start_page = page,
            secret = '-=secret=-')

    app.register_page(page,StdForm(page))

    return app.run(Request(req))

and then in the StdForm class:

    def page_process(self, ctx):

        ctx.request.status(apache.HTTP_MOVED_PERMANENTLY)
 
ctx.request.write_header('Set-Cookie',cookies['beenhere'].OutputString()
)
        ctx.request.write_header('Location','https://gohere.com/')
        self.page = "store_redirect.html"

    def page_display(self, ctx):

        ctx.run_template(self.page)

(again I snipped out a lot of other code).  I've looked though anything
in the docs I can find on status(), but there is no mention of any
special requirments that I'm not doing already.

Thanks,
Mike



More information about the Albatross-users mailing list