[mod_python] global variables are not made global?

Mephisto badmephisto at gmail.com
Sun Jul 20 22:41:05 EDT 2008


Hi, thank you fro your reply. I should have been a little clearer. I am
running Windows XP and the entire code is processed within one single
request, so I don't see how the problems with different interpreters should
affect me. Is there something else that I could try?

On Sun, Jul 20, 2008 at 9:54 PM, Graham Dumpleton <
graham.dumpleton at gmail.com> wrote:

> 2008/7/21 Mephisto <badmephisto at gmail.com>:
> > Hi, I have been trying to fix this for a while, but I cant seem to do it:
> >
> > essentially this is my code:
> >
> > in my main .py file that handles requests:
> > from otherfile import othermethod
> > def handler():
> > global a
> > a=5
> > othermethod()
> >
> > in otherfile:
> > def othermethod()
> >    #in this method, the value of a is not defined, even though i made it
> > global!
> >
> > even though it says in the documentation that global data is normally
> > retained and handled. And all of the previous code runs within the same
> > request... am i doing something wrong? or not doing something?
> > thank you
>
> Read:
>
>
> http://www.dscpl.com.au/wiki/ModPython/Articles/TheProcessInterpreterModel
>
> Apache is a multiprocess web server (except on Windows), thus
> subsequent requests will not necessarily be handled by the same
> process.
>
> It is not clear from your example whether you are talking about data
> persisting across requests, or whether you are talking about data seen
> by other modules imported as part of same request.
>
> BTW, relying on globals is also dangerous for configurations where
> Apache is running multithreaded.
>
> That document summaries issues about global data and persistence at the
> end.
>
> Graham
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20080720/9643b4c5/attachment.html


More information about the Mod_python mailing list