User Tools

Site Tools


info:python_web_frameworks

Web Frameworks

Full Stack Python (online open book) has a lot of general information on creating a "production Python web application".

Django

See Django. This is the only one I've actually used any amount so far.

Unlike Pylons/Pyramid/Turbogears, which use (or have the option to use) SQLAlchemy, Django has its own ORM. Django also has a nice automatic admin interface.

One advantage of using the Django ORM is that you can keep extra information such as labels (translatable) as par of the model.

The Django package is fairly large in size (~7MB), but is not that much more than e.g. Pyramid + its dependencies + SQLAlchemy.

Django appears to have the largest community. For example, going by PyPi numbers (2014-09-19), it has ~10× the number of downloads as Pyramid; the gap with Flask is smaller (~2×). Of course those numbers may not necessarily mean much.

Pyramid

Merger of Repoze.bfg and Pylons.

  • Cornice "provides helpers to build & document REST-ish Web Services with Pyramid, with decent default behaviors. It takes care of following the HTTP specification in an automated way where possible."
    • Just handles the interface part - nothing for SQLAlchemy/serialization

Pylons

Merged into Pyramid.

Interesting essay about Pylon's plethora of developer choices: Frameworks Exist for Conceptual Integrity

Flask

A micro-framework. Seems to be getting fairly popular.

Packages:

REST:

    • Originally developed to support MongoDB; now adding SQLAlchemy support
    • Features include conditional requests (modified since), concurrency control (ETag), bulk inserts, versioning, rate limiting (uses Redis), "Operations Log" (queryable log of all edit operations), HATEOAS data (links to help explore the API programmatically)
  • flask-sandboy (related to sandman)
    • "Like sandman, Flask-Sandboy automatically generates REST APIs. Unlike sandman, it does so from existing Flask-SQLAlchemy models."
  • Several others

TurboGears

cf. podcast: http://talkpython.fm/episodes/show/35/turbogears-and-the-future-of-python-web-frameworks

  • Full-stack framework composed of several 3rd-party components. Also intended to be able to work in a "microframework" style (I believe this works with the "TurboGears2" package, which only has, as of now, 4 fairly small dependencies).
  • Supports both relational databases (using SQLAlchemy) and MongoDB
    • Built-in support for connecting to an online/read-only standby pair of SQL databases
    • MongoDB support uses Ming; migration support seems to be lacking compared to SQLAlchemy or Django
  • Has an admin interface
  • The default template engine, Genshi, has apparently had some trouble keeping up to date (e.g. with Python 3.4); might consider using one of the others (e.g. Kajiki, Jinja2, Mako)

Others

  • Hug - simple web APIs
    • Python 3 only; possibly faster than other frameworks 1)
  • Bottle - Another micro-framework
  • Grok - Based on Zope / ZODB (Zope object database).
  • web2py - Basically everything can be done through the web interface.
  • Omega - interesting idea from Jeff Knupp, but was not developed very far

WSGI Servers

A Comparison of Web Servers for Python Based Web Applications

  • waitress and gunicorn are small, and don't have extra dependencies; either seems a good default choice 2)
  • pulsar also has a WSGI server; also seems to have a lot of other things (based on asyncio)
info/python_web_frameworks.txt · Last modified: 2016-05-23 18:30 by sam