[mod_python] global var on 2.7

antoine rouadec at gmail.com
Sun Jul 10 07:28:58 EDT 2005


Hello,

I've this problem trying to get a particular var to be loaded once and
for all using mod_python 2.7 on apache 1.3 (debian sarge stable) with
python 2.1. The same code worked perfectly well with mod_python
3.1/apache2/python2.3 but I've been a little bit too optimistic on my
hosting server uptodateness and spent the last week with downgrading
issues...

So I'm using the publisher handler and here is a resume of my index.py:

bigdic = None

def index(req):
  global bigdic
  if bigdic:
    req.write("bigdic already loaded")
  else
    req.write("bigdic loading...")
    bigdic = loooong_and_painfull_process()
    req.write("done, pfiouh")

this work perfectly well with the new components (apache2 and all) but
not with the old one (apache1.3 and company) which I _have to_ use,
meaning I get the "bigdic loading....done" message every time I reload
the page.

I tried the PythonImport but it segfaults apache (wether at the
virtual host level or the directory level)

I'm not running out of idea yet but before I get into crazy mode
looking for a complicated solution has any of you encounter and
resolved the same problem before?

Just to make it clear : upgrading any of the component is not an
option, I could rewrite/patch the publisher handler though.

Thanks for your time
-- 
Antoine
http://delaunay.org/antoine



More information about the Mod_python mailing list