ModPython: passing variables between handlers?
Diez B. Roggisch
deetsNOSPAM at web.de
Thu Feb 3 08:38:54 EST 2005
> import modpython
> ....
> def handler():
> # main part of the application starts here
> ...
>
> def authenhandler():
> ...
> # Store information about the user in an object
> u = new User(req.user, pass)
<snip>
> What I'm really looking for is some sort of global dictionary like PHP's
> $REQUEST or $SESSION, which I can assign freely to during the life of
> the request *from anywhere in my application* and which gets cleaned up
> for me automatically afterwards. Does something like this exist in
> mod_python?
>
> If the approach above isn't possible, what would your recommendations be
> for a solution to this issue?
I have absolutely no experience with mod_python, so take this with a grain
of salt - but you code above suggests that there is a request object: req.
You already use it: req. How about storing u in req like this:
def authenhandler():
# Store information about the user in an object
req.u = new User(req.user, pass)
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list