Run Python as separate process with Apache?
Skip Montanaro
skip at mojam.com
Mon Jul 10 17:57:35 EDT 2000
Randall> In news:<14697.3435.929500.668699 at beluga.mojam.com>, skip at mojam.com
Randall> says...
Randall> 1) Have a persistent Python process that processes http
Randall> requests.
>>
>> Yup, Medusa, Zope, the ZServer part of Zope (which is a lightly
>> touched up Medusa),
Randall> Is ZServer written in Python?
Yup. There may be a helper module or two written in C, but they would be
small things.
Randall> Is all of Zope a Python-based app server?
Yes, pretty much.
Randall> I went and looked at the http://www.zope.org site (I've seen
Randall> Jon Udell rave about it in the past btw) and saw that it sounds
Randall> like it is somehow more tightly tied to Python than to other
Randall> scripting languages. Is that correct?
Well, you can write new methods or products in Python and you can write
methods in HTML. ActiveState is working on methods in Perl I believe, but I
don't know the timeframe.
>> or something based on the HTTPServer class in the Python core should
>> do the trick. I use ZServer listening on 127.0.0.2 at port 9673 and
>> have Apache running on the same machine with proxy support. It then
>> proxies to the server only those things I want the ZServer to see.
Randall> So there is a plug-in for Apache that can route requests to
Randall> ZServer?
I just use mod_rewrite to map interesting requests, e.g.:
RewriteRule ^/(.*)\.shtml http://127.0.0.2:9673/filter?file=$1.shtml [P]
which says to map any .shtml requests to the filter method on the ZServer.
Randall> So this is possible to do with Apache and ZEngine and Apache
Randall> can still handle all URLs that don't have a leading /webapps
Randall> pattern?
*Everything* is possible with mod_rewrite... ;-)
>> My ZServer then talks to a MySQL database using the MySQLdb module.
>> If you want SQL connection capability I suspect you'll find Zope is
>> much closer to a complete solution.
Randall> Does ZServer support other RDBMSs?
Yes, though I'm not expert enough to know all of them. I know they support
Gadfly and Oracle. Don't know about Postgres.
Randall> With the Servlet API the actual act of asking for a session id
Randall> causes the Tomcat engine (or any servlet api compliant
Randall> container) to create one if it already doesn't exist and then
Randall> to go set a cookie on the client browser all seamlessly without
Randall> your having to do anything. Then it will do timeouts on the
Randall> session id based on how long since it was last asked for. I'm
Randall> hoping I can find something as slick and automatic in the
Randall> Zope/Python world.
I wouldn't be surprised. You might want to ask at zope at zope.org.
--
Skip Montanaro, skip at mojam.com, http://www.mojam.com/, http://www.musi-cal.com/
"To get what you want you must commit yourself for sometime" - fortune cookie
More information about the Python-list
mailing list