ModPython: passing variables between handlers?
Steve Holden
steve at holdenweb.com
Thu Feb 3 10:09:59 EST 2005
Diez B. Roggisch wrote:
> Hi,
>
> first of all - please quote appropriately - especially if you receive the
> postings as digest. That prevents the signal-to-noise-ratio dropping to
> unknown lows...
>
>
>>Your responses will give me the required lifetime for my variables, but
>>not the required access at all levels of code (unless req is a global
>>variable?).
>>
>>Do you have any other suggestions as to how this might be implemented?
>
>
> If the code you showed us _is_ what you use - then req seems to be a global
> variable. Otherwise it won't work.
>
>
Yes, I've changed the subject line to try and avoid too much further
confusion.
Andrew, you are aware, I take it, that the request object is provided as
an argument to each handler that's called for a request?
Using any kind of global in mos_python code is dangerous because of the
potential for one request's changes to overwrite another's. I've had to
deal with similar complications in my own code, but you may want to
think about biting the bullet. Globals are almost always a bad idea in
multi-user contexts like this.
regards
Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005 http://www.pycon.org/
Steve Holden http://www.holdenweb.com/
More information about the Python-list
mailing list