[mod_python] How to make mod_python (Win32) not torelyonregistrykey?

Graham Dumpleton grahamd at dscpl.com.au
Wed Jun 28 01:34:43 EDT 2006


Nicolas Lehuen wrote ..
> And that, my friend, is what we call an installer :).
> 
> See Inno Setup et al. But I don't think this is what Sanja wants.
> 
> Is the SetEnv directive correctly working on Win32 ? For example, if I
> have a CGI program, does it effectively receive the environment
> variables set in the .conf file ? If so, I don't understand why Python
> is more cooperative...

As I pointed out in very first followup (and no one corrected me to say
I was wrong), my understanding is that the Apache SetEnv directory
merely sets an entry in a table object which is then used to populate
the environment of CGI scripts when run. That is, SetEnv doesn't actually
change the environment of Apache itself, thus mod_python wouldn't see
any values set by SetEnv in sys.environ.

  http://httpd.apache.org/docs/2.0/mod/mod_env.html#setenv

Code from httpd which is triggered by SetEnv is:

static const char *add_env_module_vars_set(cmd_parms *cmd, void *sconf_,
                                           const char *name, const char *value)
{
    env_dir_config_rec *sconf = sconf_;

    /* name is mandatory, value is optional.  no value means
     * set the variable to an empty string
     */
    apr_table_setn(sconf->vars, name, value ? value : "");

    return NULL;
}

In other words, doesn't call putenv() so can't be used to set PYTHONHOME or
PYTHONPATH.

Graham

> Regards,
> Nicolas
> 
> 2006/6/28, Lee Brown <administrator at leebrown.org>:
> > Greetings!
> >
> > BINGO!  This is a PYTHON problem, and I doubt that you'll solve it without
> > patching python's source code.
> >
> > However, I have seen a python module that manipulates Windows Registry
> data.
> > I suspect that your most expedient solution will be to write a small
> program
> > to add the needed information to the registry, convert that program to
> an
> > EXE file, and then execute that from a batch file when you plug your
> 'usb
> > based' server into the host machine.
> >
> >
> > Best Regards,
> > Lee E. Brown
> > (administrator at leebrown.org)
> >
> > -----Original Message-----
> > From: mod_python-bounces at modpython.org
> > [mailto:mod_python-bounces at modpython.org] On Behalf Of Nicolas Lehuen
> > Sent: Tuesday, June 27, 2006 11:16 AM
> > To: sanja at bougakov.com
> > Cc: mod_python at modpython.org
> > Subject: Re: [mod_python] How to make mod_python (Win32) not to
> > relyonregistrykey?
> >
> > I'm not sure this is a mod_python problem, rather a Python problem.
> > There is a "Movable Python" project which is precisely what you may want
> : a
> > Python distribution that doesn't need to be installed.
> > Apparently the server is down right now, but you'll find it here :
> >
> > http://www.voidspace.org.uk/python/movpy/
> >
> > Anyway, let me get things clear : what you would like is to be able to
> > specify relative paths in the PythonPath directive, right ? So it's not
> > related anymore with the need to set environment variable.
> >
> > Have you just tried to use the PythonPath directive, and NOT the environment
> > variable, providing it absolute paths for a starter ? We must first check
> > whether the PythonPath directive solves the problem if provided with
> > absolute paths, before trying to patch it to accept relative paths.
> >
> > Regards,
> > Nicolas
> >
> > 2006/6/27, sanja at bougakov.com <sanja at bougakov.com>:
> > > It doesn't seem to be the perfect option - it will keep ugly DOS
> > > window open all the time Apache works.
> > >
> > > Maybe someone will suggest how to patch mod_python sources to specify
> > > PYTHONPATH relative to the location of mod_python.dll?
> > >
> > > Yours,
> > > Sanja
> > >
> > >
> > > > I think that's the way to go, because it looks like Python doesn't
> > > > like the environment variables set by Apache. I need to investigate
> > > > more, but your solution, John, is a sure bet.
> > > >
> > > > Regards,
> > > > Nicolas
> > > >
> > > > 2006/6/27, John Keyes <john.keyes at secantus.com>:
> > > >> I think he can still do it if he launches apache from a batch file.
> > > >> Inside this batch file set the PYTHON_HOME.  This
> > >
> > >
> > > _______________________________________________
> > > Mod_python mailing list
> > > Mod_python at modpython.org
> > > http://mailman.modpython.org/mailman/listinfo/mod_python
> > >
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> >
> >
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python


More information about the Mod_python mailing list