|
Jorey Bump
list at joreybump.com
Tue Oct 17 16:16:58 EDT 2006
Sells, Fred wrote:
> Do you mean that each "application" is a single minimal file (which imports
> the meat and potatoes) and that all these minimal files are in one common
> directory?
Yes. While there are exceptions, my published modules often look like this:
import example.app.foo
def admin(req):
return example.app.foo.admin(req)
def spam(req):
return example.app.foo.spam(req)
def index(req):
return example.app.foo.eggs(req)
> If that's the case, how do you extend sys.path to include the backend logic
> directories? We had been using the .pth file in the site-pachages to
> specific a "corporate library node" with each application in a subdir of
> that node. Unfortunately that technique does not seem to work with
> mod_python, or perhaps I just am stumbling in the dark.
In the VirtualHost container, I define PythonPath:
PythonPath "['/var/www/vhosts/www.example.com/python'] + sys.path"
Then I can keep application and utility code specific to a virtual host
in its own local directory, outside of the DocumentRoot. The benefits
are mainly organizational, but it also helps to keep code out of view in
case of a server misconfiguration. Be warned: Other apparent security
benefits might be imaginary if all virtual hosts run as the same user.
|