|
Adam
adam at fastmail.com.au
Fri Oct 31 21:06:39 EDT 2008
Hi,
I've made a CGI web app for managing DNS zones. I want to convert my
scripts so they use mod_python instead of cgi, but I can't really find
any good examples which demonstrate a standard way of doing what I want.
So everything to do with my website is stored in this directory:
/var/www/localhost/BDNS
This directory has three subdirectories.
-config
-content
-templates
-scripts
config - holds user and zone configuration
content - originally stored CGI files and templates.
scripts - stored the scripts to handle dns updates and manage configuration
Now I'm wondering whether this directory structure should be reognanised
if I want to use mod_python. The issue is that my documentroot in apache
is configured to /var/www/localhost/BDNS/content and I cannot refer to
my config files in mod_python using relative path names. This was not an
issue when I was using CGI.
Consider this as a simple example. I have a file index.py which wants to
open a config file in the config directory.
--------------------index.py--------------------
from mod_python import apache
bdns = apache.import_module("../scripts/bdns.py")
tmplutils = apache.import_module("../scripts/tmplutils.py")
import sys
def index(req):
f = open("../config/bdns.conf")
return f.readlines()
--------------------------------------------------
This code above doesn't work when I browse to index.py. I don't want to
use fixed path names.
Any help with organising my files and folders would be appreciated.
Adam
|