On Jul 1, 2013, at 3:06 AM, Phil Mayers <[email protected]> wrote:
> I love Twisted, but... consider carefully if an asynchronous webserver is
> what you need. A more traditional framework, like Django running under
> Apache/mod_wsgi, may suit your needs. Then again, it may not...
If you are going to use Twisted, consider using it in combination with Klein
<https://github.com/twisted/klein>. Klein is a little bit higher level and
helps you build the scaffolding necessary to assemble a site out of a bunch of
objects.
However, I think Phil's correct insofar as he recommends that Django might be
better suited towards the web application parts of your problem. mod_wsgi,
though? No need for that :).
Another combination, the one I would recommend, would be Django running under
Twisted. Twisted's WSGI container can run Django just fine (although it will
need a little help - <https://github.com/clemesha/twisted-wsgi-django> - since
Django isn't really a WSGI app, it's a WSGI-plus-some-stuff app).
Twisted (mostly) a web server, for doling out resources, where as Django is
(mostly) a web framework for developing web applications.
You can use either for either, of course; Twisted has a web app framework and
Django has a built-in web server.
Although Twisted's web-frameworky bits (twisted.web.template, adbapi, cred,
guard) are encouraged more for production use than Django's web-server-y bits
(runserver.py), if you're developing a reasonably standard web app that just
needs to manipulate a little database state, Django will be a lot easier to
work with, not to mention fantastically documented.
The web-frameworky bits of Twisted tend to have advantages when one is making
web interfaces to things which aren't simply database-backed HTML applications.
For example, a web interface which allows you to view live data-flows, or
controls some kind of hardware. Or, for developing the web interface for
something which has a model that might also be accessed by other protocols,
like IMAP, DNS, NNTP, and so on.
For example, Twisted doesn't have an ORM of any kind (since your state might
live in any kind of database, or no database at all!), and it's still a bit of
an open question in the community what the best way to interact with
database-backed state from Twisted is. By contrast, Django has an ORM that can
automatically generate a web interface to allow administrators to manipulate
any Django model in your application.
Plus, if you use Django to develop your application but run it within a Twisted
WSGI container, you can leverage the power of Twisted at any time. Itamar has
even recently released a tool to help you do this almost automatically,
Crochet:
<http://blog.futurefoundries.com/2013/05/announcing-crochet-07-easily-use.html>.
Hope this is helpful!
-glyph
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web