[Twisted-Python] Passing messages from HTTP Request to another factory or protocol

Don Schoeman don at delphexonline.com
Wed Nov 18 15:01:46 EST 2009

Hi guys,

I am busy developing a gateway of some sort and have the following
running so far on the reactor:
- HTTP Server listening for incoming connections and HTTP requests.
- LineReceiver client permanently connected to another server.
(Connection is established at startup)

What I need to do is to first translate and then pass messages received
at the HTTP listening end - over to the LineReceiver client. The client
in turn will pass it on to a server using a custom protocol called SSMI,
for example:

Web Browser Requests -> HTTPServer -> SSMIClient -> ServerXYZ

For the HTTPServer I'm using the classic design where you inherit from
twisted.web.http.Request for the Protocol, while having
twisted.web.http.HTTPChannel and twisted.web.http.HTTPFactory inherited
classes to support it.

Also, there will only ever be one SSMIClient protocol instance whereas
the HTTPServer needs to process multiple requests at a time, so it will
be a many-to-one design.

What I need to know is how to pass the "packets" received by the
HTTPServer onto the SSMIClient protocol..? I am assuming one would use
deferreds, but the twisted.web.http.Request derived class seemingly does
not have "access" to the Reactor or it's Factory object. But to be
honest, I'm a little in over my head on this and don't even know how to
approach this. I don't know whether I should use a FIFO queue to store
the messages and I don't even know where to keep such a queue. If anyone
have done something even remotely like this I'd love to get some input
from you. It will be greatly appreciated!

Kind Regards,
Don Schoeman

More information about the Twisted-Python mailing list