I use a mod_python publisher function which calls the main() function of another python script with a custom built argv list. When I execute the publisher script from shell command line it works. But when I tried it through apache2 with mod_python, I get the error (shown below) that main takes no arguments.
File "/var/www/wabaServ/waba.py", line 15, in index
aba.main([ "aba.py","-i", "-b"])
TypeError: main() takes no arguments (1 given)
main() in aba.py is defined as:
def main(argv=None):
--code--
Note: if the list argument is not passed, aba.main() gets executed from mod_python.
The mod_python publisher function looks like:
import sys
sys.path.append("/u/scripts")
import aba
from cStringIO import StringIO
def index():
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
aba.main([ "aba.py","-i", "-b"])
sys.stdout = old_stdout
return(mystdout.getvalue())