[mod_python] test doesn't work (solved?)

Gregory Trubetskoy grisha at modpython.org
Sun Jun 25 15:55:04 EST 2000


On Sun, 25 Jun 2000, Dave wrote:

> I've been using the Location directive for a bit now, here is how it
> looks for me:
> 
> <Location /wpy >
>   SetHandler python-program
>   PythonDebug On
>   PythonPath "sys.path+['/devel/WEB/Webware/WebKit']"
>   PythonHandler webkit_handler
> </Location>
> 
> The key here is the undocumented feature of PythonPath that it
> apparently evals its argument. I've been meaning to ask about this since
> at some point this could get broken in development and I'd be up a
> creek. 

I don't think this is going away - there is no simpler way to specify the
pythonpath than in python syntax which implies evaling.

> This is certainly handy but what isn't nice is that I suppose
> /something/wpy is also being appended to the PYTHONPATH wether I want or
> not.  

Yes, it's "/wpy", actually. Unfortunately, there is no way to tell at the
time the directives are being processed whether it's <Location> or
<Directive>. One option may be not to intriduce another directive,
something like PythonDoNotModifyPath or something. 

> Maybe a directive to append paths to the default PYTHONPATH would
> be in order?

Originally, I considered something like using "+['/some/path']" to mean
append or "['/some/path']+" to prepend. There turned out to be some not so
obvious issues, such as the fact that with .htaccess, the directive gets
processed with every hit, so you would have to make sure to act on it only
once, the first time.

It _could_ be done, but it went against my principle to keep it simple, so
I decided to save for it later since I had more important features to
roll out.

> BTW, the nice thing about using Location is the fact that for the
> particular application I'm using there is only a single handler and all
> content is delivered through that handler by the application. Having to
> specify a Directory just doesn't seem quite right.

Not sure I understand this completely - could you elaborate a bit?

Grisha




More information about the Mod_python mailing list