Using Twisted with django
I want to handle reporting part of my app with Twisted and rest will be handled with Django. I have Django setup on mod_python. There is some mention of "I want a container for my WSGI application" in TwistedMatrix. Does it mean twisted just handle the request and forward to some other framework? Does TwistedMatrix support mod_python? Can I use twisted with django models and django templating system? Thank you. John
On Mon, 12 Mar 2007 10:06:58 -0400, Ram Peters <rampeters@gmail.com> wrote:
I want to handle reporting part of my app with Twisted and rest will be handled with Django. I have Django setup on mod_python. There is some mention of "I want a container for my WSGI application" in TwistedMatrix. Does it mean twisted just handle the request and forward to some other framework? Does TwistedMatrix support mod_python? Can I use twisted with django models and django templating system?
There is some experimental support for using Twisted as a WSGI container. Zope is using it, with some success as far as I am aware. If you use WSGI, however, you lose pretty much all the Twisted request processing features. It is pretty unlikely that Twisted will work inside mod_python, and there wouldn't be any reason to use it there anyway, since you already have an HTTP server. I haven't used Django so I can't say whether or not it will work well in a Twisted server. If it performs blocking operations (for example, to talk to a database), then it probably won't work very well. Jean-Paul
Some where in the documentation, I read you can do blocking stuff like access to database using twisted.enterprise.adbapi. I don't really see, why, anyone want to use Twisted for other than writing their on communication protocol like BitTorrent. John On 12/03/07, Jean-Paul Calderone <exarkun@divmod.com> wrote:
On Mon, 12 Mar 2007 10:06:58 -0400, Ram Peters <rampeters@gmail.com> wrote:
I want to handle reporting part of my app with Twisted and rest will be handled with Django. I have Django setup on mod_python. There is some mention of "I want a container for my WSGI application" in TwistedMatrix. Does it mean twisted just handle the request and forward to some other framework? Does TwistedMatrix support mod_python? Can I use twisted with django models and django templating system?
There is some experimental support for using Twisted as a WSGI container. Zope is using it, with some success as far as I am aware. If you use WSGI, however, you lose pretty much all the Twisted request processing features.
It is pretty unlikely that Twisted will work inside mod_python, and there wouldn't be any reason to use it there anyway, since you already have an HTTP server.
I haven't used Django so I can't say whether or not it will work well in a Twisted server. If it performs blocking operations (for example, to talk to a database), then it probably won't work very well.
Jean-Paul
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
On Mon, 12 Mar 2007 16:36:10 -0400, Ram Peters <rampeters@gmail.com> wrote:
Some where in the documentation, I read you can do blocking stuff like access to database using twisted.enterprise.adbapi.
Yes. But does Django use this? :)
I don't really see, why, anyone want to use Twisted for other than writing their on communication protocol like BitTorrent.
Some people find it easier than writing threaded code. Other people need better performance than threaded solutions can provide. Other people want to use some protocol which has a Twisted implementation. Jean-Paul
I think I am understanding it now, Twisted handles request for you. So you don't need Apache + Mod_Python. You just have to put in a loop and tell Twisted to listen to the port. For example, I just tell it to listen to some port. def main(): factory = protocol.ServerFactory() factory.protocol = Echo reactor.listenTCP(5555,factory) reactor.run() if _name_=='_main_': main() On 12/03/07, Jean-Paul Calderone <exarkun@divmod.com> wrote:
On Mon, 12 Mar 2007 16:36:10 -0400, Ram Peters <rampeters@gmail.com> wrote:
Some where in the documentation, I read you can do blocking stuff like access to database using twisted.enterprise.adbapi.
Yes. But does Django use this? :)
I don't really see, why, anyone want to use Twisted for other than writing their on communication protocol like BitTorrent.
Some people find it easier than writing threaded code. Other people need better performance than threaded solutions can provide. Other people want to use some protocol which has a Twisted implementation.
Jean-Paul
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
participants (2)
-
Jean-Paul Calderone
-
Ram Peters