[Twisted-Python] Twisted and mod_python?
I am wondering about the feasibility of using mod_python in an Apache server to make PB requests to a Twisted application. That is, I have a Twisted application which servers PB requests, e.g. a user manager. I also have an Apache server. I would like the Apache server to present dynamic web pages based on the contents of the user manager application, to act as a web front end (e.g. create/erase/modify user properties). I was thinking that it could be possible to use mod_python and Twisted to act as a client to the user manager. My questions are: 1. Is this possible, fesible and/or reasonable? If so, any hints or examples would be welcome. 2. Any alternative/better solutions? I suppose it would be rather easy to use CGI instead, but I'd like to explore the options. - Patrik
On Tue, 11 Nov 2003 16:31:54 +0100
"Patrik Blommaskog"
I am wondering about the feasibility of using mod_python in an Apache server to make PB requests to a Twisted application.
You'd need to start the Twisted event loop up on each HTTP request. Or... kinda. It's possible anyway, but you'll need to investigate mod_python's interpreter lifetime model. -- Itamar Shtull-Trauring http://itamarst.org/ Available for Python & Twisted consulting
Itamar Shtull-Trauring wrote:
You'd need to start the Twisted event loop up on each HTTP request. Or... kinda. It's possible anyway, but you'll need to investigate mod_python's interpreter lifetime model.
It's theoretically possible, but almost certainly a bad idea. Do you already have a large mod_python-using codebase? If not, Twisted includes HTTP support for a reason. Just use it :). To communicate with your apache server, use mod_proxy or something similar to just relay requests to the Twisted web server. If you do have a large mod_python-using application already and you are trying to get it to talk to Twisted, you probably want to continue to use the mod_python execution model rather than spin up the twisted event loop and switch back and forth: while it's possible if you really need it, a better architectural strategy in the average case (to avoid odd interactions between the assumptions mod_python has about its environment and the assumptions twisted has about its) would be to use Twisted's XMLRPC support and talk to it using a blocking XMLRPC library from your mod_python scripts. but-ask-me-again-when-warner-finishes-newpb-ly y'rs, -glyph
participants (3)
-
Glyph Lefkowitz
-
Itamar Shtull-Trauring
-
Patrik Blommaskog