473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Need to pass variables from mod_python publisher to standalonescript.

There's a problem which I'm trying to solve as elegently as possible.

Its basically a setup that runs mod_python on Apache and its for a
client that needs to generate dynamic reports by pulling out records
from Postgres.

Now once the report is generated , we mail the report in csv format to
the requested mailid.

We're trying to seperate the report generation / mailing part from the
mod_python code by
passing the report parameters to an external python script and
processing & mailing the report externally from the httpd daemon .

We want to do this because some of the reports take something like 5mins
or more and its really painful for
having to wait for the report to download etc. (believe me its about a
couple million records in the db) .

The solution I have is something like this
1. Create the a script test.py
which can be called like so -
../test.py -b "{'username': ['motorola'], 'tmonth': ['1'],
'metrics_select': ['0'], 'dateperiod': ['2'], 'keyword': ['tablecloth']}"
The parameter would actually be a dict that is processed by mod_python
and converted into a string.

2. test.py has a function convert_both() which converts the string that
is passed into a dictionary (attached below).
The code works well so far.
>> test.py >>>>>>

#! /usr/bin/python
import sys
import getopt
import t

#for argv in sys.argv : print "args = ",argv

def main(argv):
try :
opts , args = getopt.getopt(argv,"hg:b:d",["help","grammar="])
except getopt.GetoptError:
sys.exit(2)

for o,a in opts :
if o in ("-b","--both"): return a

if __name__ == "__main__":
both = main(sys.argv[1:])
print "args(both) = ",both

d = t.convert_both(both)
print 'd = ',d
# Other processing like db transactions & mailing csv files done later.
3. The issue is currently to be able to invoke this script from within a
mod_python code .
../test.py -b "string from a dictionary" ( needs to be called from a
python script to work)

Also I have my doubts if this could be solved in any better way .

~Anthony

Jul 18 '05 #1
0 1259

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: charlie knudsen | last post by:
I am setting up mod_python 2.7.10 on Apache 1.3.33 as a dso and was wondering if there is a default function that is called when the publisher handler is not given a function. I have read through...
0
by: Julien Cigar | last post by:
Hello, I'm using mod_python 3.1.3 with Apache 2.0.54 on a Debian box with the publisher handler and the Clearsilver template engine, and from time to time apache returns an 500 error code...
0
by: Python_it | last post by:
I'm going to work with mod_python. I install mod_python 3.2.2b for python 2.4. If i test my install with mptest.py see this link:...
6
by: Little | last post by:
I can't figure out how to build this type of program using the publisher handler. I have the following connected to the program SetHandler python-program PythonHandler mod_python.publisher...
6
by: Anthony L. | last post by:
I am writing a web application that is comparable to a content management system used in blogging. I really want to use Python after having done some evaluation coding using Python 2.3.5 with...
2
by: exhuma.twn | last post by:
Hi again, as soon as I try to make use of the "session" object inside a psp-template file, I get the following error: Mod_python error: "PythonHandler mod_python.publisher" Traceback (most...
2
by: m.banaouas | last post by:
I installed Apache 2.2.3 and mod_python 3.2.10 on WinXP plateform I configured mod_python via httpd.conf: LoadModule python_module modules/mod_python.so but my script folder configuration...
0
by: Simo D | last post by:
Hi, I'm using a script.py to write a file in a dir on the server. Mod_python work but i get: Mod_python error: "PythonHandler mod_python.publisher" Traceback (most recent call last): File...
0
by: Simo D | last post by:
Ok, solved: apache is unable to follow relative paths from the script. Putting ol absolute paths it's ok! Simo D wrote: -- View this message in context:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.