473,790 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to pass variables from mod_python publisher to standalonescrip t.

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(a rgv,"hg:b:d",["help","grammar ="])
except getopt.GetoptEr ror:
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 1278

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

Similar topics

1
2411
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 some documentation and it looks like mod_python 3.x defaults to the index function, but that does not appear to work for 2.7. Also I am using python 2.3.4. I have the following file as index.py in the test directory of my web root: from...
0
1607
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 (Internal Server Error). Apache errog.log file looks like : PythonHandler mod_python.publisher: Traceback (most recent call last): PythonHandler
0
1806
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: http://www.modpython.org/live/mod_python-3.2.2b/doc-html/modpython.html IT WORKS!
6
3663
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 PythonDebug On But what I would like to do would be have a german word as the parameter in the HTTP request and have the english world printed out on the screen. Yes this will be a small dictionary but I just want to be able to understand how to...
6
1948
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 mod_python 3.1.4 running on Apache 2.0 with the Publisher handler. However, I am still very hesitant to settle on Python. All my research brings up the same collection of scant articles and old mailing list messages that reference each other. I am...
2
3313
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 recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
2
3234
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 doesn't work correctely: Alias /myfolder D:/myfolder <Directory "/myfolder"> Order allow,deny
0
1744
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 "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req)
0
2361
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: http://www.nabble.com/Mod_python-permission-denied-tp20377387p20378315.html Sent from the Python - python-list mailing list archive at Nabble.com.
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.