Originally inspired by RubyOnRails it's based on MVC where the controller dispatches the request to a set of actions exposed from the controller itself.
TurboGears, in its full stack mode, provides all the features you would require during development of a web application:
It's also one of the few web frameworks officially supporting MongoDB as one of the primary storage backends, including support into the TurboGears Admin to autogenerate CRUDs from MongoDB models.
While TurboGears has always been a full stack framework with same scope of projects like Django, it differentiates from other frameworks due the its philosophy on two major parts of a web framework: Templating and Routing
While TurboGears provides support for multiple template engines, the primary one has always been a fully validated XML template engine.
Currently TurboGears ships with the
Kajiki template engine,
which was developed within the project itself, but in the past
it relied on the Genshi and Kid template engines which were
mostly syntax compatible with Kajiki.
Historically validated xml template engines has always been slower than text template engines, but the Kajiki project was able to create a very fast template engine that usually renders faster than Mako or Django Template while still retaining all the expected features.
The fact that it relies on a validated XML engine provides some benefits compared to plain text engines like Django Template, Jinja2 and Mako:
It automatically escapes content rendered into the template, thus making easier to avoid XSS and injection security issues:
will render as
thus preventing any form of injection from user provided content.
The template engine parses the provided template document and recognises the nodes that contain static text.
As the engine is able to distinguish text from markup it's able to flag the text for translation.
<div>Hello World</div> would get automatically
translated if a translation for
"Hello World" is provided,
without having to wrap text in
As the template engine syntax is purely valid XHTML the template itself can be opened with WYSIWYG editors and as far as they don't strip unknown attributes the template can be edited and saved back from those editors.
Most web frameworks have been relying on regular expressions to declare routing, through decorators or through a routing map.
TurboGears supports regular expressions through the
extension, but the preferred way of routing is through the
Object Dispatch system.
In Object Dispatch a root controller object is traversed while resolving the URL. Each part of the url path is mapped to a property of the controller (Which might point to a sub controller) until a final callable action is encountered.
This leads to a very natural mapping between URLs and the code serving them, allowing people with minimal knowledge of a project to jump in and quickly find actions in charge of serving a specific page.
In Object Dispatch an URL like
would be served by a hierarchy of objects like:
class UsersController(TGController): @expose() def new(self, name=None): return 'Hi, %s' % name class RootController(TGController): users = UsersController()
It's easy to see how
/users/new actually resolves
RootController.users.new and all options provided
to the URL are passed to the action serving the response
TurboGears Introduction Video An overview of TurboGears2 features presented at the PyConWeb
TurboGears Documentation The official TurboGears documentation
Microframework Mode Tutorial The official tutorial that focuses on starting TurboGears in microframework mode and leads to developement of a single file web application
FullStack Tutorial The Wiki in 20 minutes tutorial that showcases how to create a fully functional wiki application with TurboGears in full stack mode.
The CogBin The CogBin is a list of the most common pluggable applications for TurboGears, it enlists ready made pieces you can plug into your web application to provide features like Facebook Login, Comments, Registration and so on...
React in Pure Python An article showcasing how to create web applications relying on React without the need to have NodeJS installed at all. The article uses TurboGears as the web framework to develop the example application.
Easily deploy your Python web apps to Digital Ocean's reliable cloud computing platform.
Secure and manage identities in your Python web apps with Okta.
Easily build maps, search and navigation into your Python applications with Mapbox.
Scout monitors the performance of your Python apps, identifying slow queries, memory bloat, and more. Free during Tech Preview.
Upgrade your Python skills by reading Real Python's awesome programming email newsletter.