[mod_python] Sessions, still

Colin Fox cfox at cfconsulting.ca
Mon Apr 5 00:16:44 EST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, I've discovered why the session stuff I was doing wasn't working.
I didn't realize that the util module had a redirect, so I was doing it
myself with this code (which I got from the docs somewhere...):

def old_redirect(req, url, temporary=False, seeOther=False):
~    """
~    Immediately redirects the request to the given url. If the
~    seeOther parameter is set, 303 See Other response is sent, if the
~    temporary parameter is set, the server issues a 307 Temporary
~    Redirect. Otherwise a 301 Moved Permanently response is issued.
~    """


~    if seeOther:
~        status = apache.HTTP_SEE_OTHER
~    elif temporary:
~        status = apache.HTTP_TEMPORARY_REDIRECT
~    else:
~        status = apache.HTTP_MOVED_PERMANENTLY


~    req.headers_out['Location'] = url
~    req.status = status
~    raise apache.SERVER_RETURN, status


If I use that, then the session variables don't seem to work. If I use
util.redirect(), they do. What are the two redirects doing differently?

I'm also still curious when to use session.save() and session.load().

Thanks,
~  cf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD4DBQFAcQfcoaQ1/feGlJoRApL6AJdCXbpTKgQVRIwUZrg3hMxFne/CAJ4jD1sl
DM7r2orMPM/vqd8vHi5hBQ==
=qnae
-----END PGP SIGNATURE-----


More information about the Mod_python mailing list