473,386 Members | 1,706 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.

mod_python confusion

I thought mod_python would be the answer to my CGI performance issue,
but I can't seem to make much sense out of it. All the examples are
too trivial to be of much use.

Given that I have an application consisting of several CGI scripts,
what is the simplest way to go about converting it to run on
mod_python, not using the CGI-handler which is allegedly slow and
buggy? Everything seems to suggest a major rewrite because I not only
need to shift from printing everything to calling req.write or
whatever, but I may also need to sort out some sort of dispatching
mechanism mapping URLs to functions if I use mod_python directly. PSP
doesn't work on my system as 3.1.2 gives me errors and the Win32
installer for 3.1.3 fails at the last step (finding the Apache
directory in the registry or something).

--
Ben Sizer
Jul 18 '05 #1
5 1420
Kylotan wrote:
I thought mod_python would be the answer to my CGI performance issue,
but I can't seem to make much sense out of it. All the examples are
too trivial to be of much use.
I recommend using some framework that abstracts the web server - page
code interface out of the way. Jonpy is very lightweight, can be used
with standard CGI, FastCGI or mod_python without many changes and has
pretty nice interface. It is probably relatively easy to write a new
"backend" for it if you ever need to.

Given that I have an application consisting of several CGI scripts,
what is the simplest way to go about converting it to run on
mod_python, not using the CGI-handler which is allegedly slow and
buggy? Everything seems to suggest a major rewrite because I not only


Converting some simple speed-needing CGI script into something jonpy can
handle should be trivial - and with FastCGI it really helps the speed
when the interpreter starting overhead is the biggest cause for slowness.

Then there are more comprehensive frameworks, which usually have their
own server processes to which the webserver of your choice proxies the
requests. I don't know much about those, and converting to them probably
isn't as easy.
Jul 18 '05 #2
Tuure Laurinolli wrote:
Converting some simple speed-needing CGI script into something jonpy can
handle should be trivial - and with FastCGI it really helps the speed
when the interpreter starting overhead is the biggest cause for slowness.


here's a question that is of immediate interest for myself and possibly
others. How do you generalize the fast CGI type of solution to Python
programs in general? For example, I have a program that runs as a
filter off of emailrelay[1]. The long-term solution is integrating
python but that has its challenges (emailrelay is a threaded c++
application and we would want python applications to be threaded as well).

Since the integration isn't going to happen anytime soon, I am content
to run a persistent process (like fast CGI) with some glue logic handing
data over. The question is, is there a general framework for this. XML
RPC is a possibility but my experience has shown in to be a somewhat
sluggish protocol using the stock XML RPC server in Python.

it would be nice if one could make it a multithreaded server but I must
admit I haven't researched to see if the available XML RPC facilities in
Python can be threaded or at least forked.

I'm sure there are innumerable misunderstandings in my approach to this
problem so I await correction.

---eric

[1] emailrelay is a really nice mini MTA/proxy which lets you filter
messages at a variety of points.

Jul 18 '05 #3
On Saturday 29 May 2004 03:56 pm, Eric S. Johansson wrote:
Since the integration isn't going to happen anytime soon, I am content
to run a persistent process (like fast CGI) with some glue logic handing
data over. The question is, is there a general framework for this. XML
RPC is a possibility but my experience has shown in to be a somewhat
sluggish protocol using the stock XML RPC server in Python.


Have you tried the Fast Python XML RPC library?

http://sourceforge.net/projects/py-xmlrpc/

Also, you may want to host it on a server other than one from the standard
library, such as Medusa, Twisted, or Zope.

--
Troy Melhase, tr**@gci.net
--
These are the days when the Christian is expected to praise every creed except
his own. - G. K. Chesterton
Jul 18 '05 #4
Troy Melhase wrote:
Have you tried the Fast Python XML RPC library?

http://sourceforge.net/projects/py-xmlrpc/
no I had not. it does look like it's very promising although I am
hoping that there has been no release since last year means that the
code is extremely stable and bug free and not that the project is dead.
It also means that now I need to find a pair of hands/mind to help
create the C lang side in emailrelay. writing C/C++ using speech
recognition is like gargling broken glass.
Also, you may want to host it on a server other than one from the standard
library, such as Medusa, Twisted, or Zope.


I've tried to use those packages awhile back but unfortunately, at the
time I tried them, they were still pretty much a "bag of parts" and I
was not able to successfully installed them. I am also reluctant to add
these tools to my environment because already I am counting on a fair
number of external pieces.

It's gotten to the point where I have created a toolkit which I call
"raging dormouse". The download component allows you to fetch software
directly from web sites or through the source forge "click-a-link"
download maze automatically. I then wrap the download component in a
shell script which unbundle's, runs installation procedure etc. for all
the components.

It's not quite as sophisticated as a portage script, rpm, or deb but it
is relatively platform independent if the platform is some form of UNIX
with bash and python. :-)

---eric
Jul 18 '05 #5
Kylotan wrote:
I thought mod_python would be the answer to my CGI performance issue,
but I can't seem to make much sense out of it. All the examples are
too trivial to be of much use.

Given that I have an application consisting of several CGI scripts,
what is the simplest way to go about converting it to run on
mod_python, not using the CGI-handler which is allegedly slow and
buggy? Everything seems to suggest a major rewrite because I not only
need to shift from printing everything to calling req.write or
whatever, but I may also need to sort out some sort of dispatching
mechanism mapping URLs to functions if I use mod_python directly.
Basically the main performance gains from using mod_python are that you
are calling functions in an already loaded program, rather than running
a separate script each time (and the interpreter as well). So it
generally does require a redesign. But if you refactor your code step by
step this is usually achievable.
PSP
doesn't work on my system as 3.1.2 gives me errors and the Win32
installer for 3.1.3 fails at the last step (finding the Apache
directory in the registry or something).


There is a new win32 installer at
http://davidf.sjsoft.com/files/mod_p...in32-py2.3.exe which
should fix the issue (ask here or email me or see the mod_python list
for more information)

David
Jul 18 '05 #6

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

Similar topics

1
by: wolf | last post by:
i would like to briefly share my experiences with installing mod_python on a w2000 box. i must say that i believe the installation process to be unnecessarily complicated by the simple fact that...
2
by: Robert J. Hansen | last post by:
I'm not entirely certain comp.lang.python is the proper newsgroup for mod_python questions, but "comp.lang.python.web" doesn't seem to exist, so... my apologies in advance if this is considered...
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: 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...
0
by: marc.wyburn | last post by:
when POSTing a date from an mod_python psp page to another the date is sent as a string. I'm using form.has_key to pull the POST. I can cut the string up,turn the strings into integers and then...
1
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python import apache def handler(req):...
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...
5
by: m.banaouas | last post by:
Hi, bonjour, witch versions are suitable to use for apache & mod_python ? Can i install and use "Apache 2.2.3" & "mod_python 3.2.10" (most recent versions) without facing any known major...
3
by: Michael | last post by:
Hey everyone, Is it possible to automatically insert headers/footers using mod_python? I will be not be using PSP's, so I cannot use the PSP/include solution. Furthermore, the header will be...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.