Pyramid Frequently Asked Questions
What is the difference between Pyramid and Pylons, the web framework?
Pyramid is a web framework that was first released in January 2011. It doesn't "share any DNA" with Pylons 1.0. The Pylons 1.x web framework will be maintained indefinitely by The Pylons Project. There may be a Pylons 1.1 release aimed at easing a transition to Pyramid eventually. However, as of the release of Pyramid 1.0 on January 31, 2011, the Pylons web framework has effectively been shifted into "legacy" status.
Existing Pylons 1.0 code will be able to run "inside" Pyramid via the use of a fallback handler that sends requests to an existing Pylons application. When run within the fallback handler, Pylons 1.0 applications may be ported piecemeal to Pyramid. As each bit of functionality is translated into Pyramid code, the fallback application will continue to handle yet-to-be ported functionality.
Why is Pyramid any different than the hundred other Python web frameworks?
Does Pyramid run on Python 3?
Pyramid 1.3a1+ runs on Python 3.2 and better. Earlier versions run on Python 2 only.
Where are the Pyramid add-ons?
Pyramid supports extensibility through add-ons, including mailers, RPC, and debugging tools.
Where are the best places to learn Pyramid when coming from Django?
- Use a the alchemy scaffold to quickly start a project with an SQL database for persistent storage.
- You can use Jinja2 templates with the add-on pyramid_jinja2.
- Use sessions with the Beaker add-on pyramid_beaker.
- FormAlchemy can be used to recreate the Django Admin interface.
- For authentication read the tutorial by Michael Merickel.
- For forms look at Deform. Check out the Deform demos.
How do I implement event driven applications in Pyramid?
How do I implement caching in Pyramid?
How do I use MongoDB with Pyramid?
How do I validate form input and use formatting helpers?
How can I create mobile applications in Pyramid?
Pyramid and jQuery Mobile play very nicely together. Check out pyramid_jqm.
How do I serve favicon.ico, Robot.txt, and other static assets?
How do I use Jinja2 templates with Pyramid?
How do I deploy Pyramid? Which WSGI servers does Pyramid support?
Pyramid is compatible with all of the WSGI compliant servers. For development purposes paste.httpserver can be run using paster serve development.ini.
- mod_wsgi / apache
Should I port my Pylons 1.0 project to Pyramid?
Pyramid 1.0 was released on Jan 31, 2011.
We've heard reports from several Pylons users that they have ported smaller apps without too much difficulty. Akhet will help any Pylons user convert their Pylons app to Pyramid. It utilizes pyramid_handlers for routing. For larger Pylons apps, you may want to wait for the migration guide document to reach non-draft status before attempting a port.
However, there are a few things you can do now to ease a later migration to Pyramid:
Avoid the use of Pylons global objects except directly in action methods. There is no other well-known way to access them, unless self._py_object.request has been implemented.
Pylons global objects refer to 'request', 'session', 'cache', 'response', 'tmpl_context', 'config', 'url' objects that are imported from pylons.
This also affects your ability to use your domain models outside of a Pylons app (a command line script). Domain models shouldn't depend on Pylons globals to work, nor should you pass Pylons globals into class methods of your domain models. Pass variables that contain just the data the model needs.
Ensure all of your routes are explicit and named. All routes in Pyramid must be named (uniquely), and there is no minimization available.
If your Pylons app is already set up like this, then your domain models will most likely require no changes at all. Templates might need slight alterations and controllers will need some changes.
What is the difference between Pyramid and repoze.bfg?
Pyramid is repoze.bfg, with:
- a new name and a new set of import locations, and
- a few added features to meet the expectations of Pylons 1.0 users.
repoze.bfg 1.3 (made November 1, 2010) will be its last major release. Minor updates will be made for critical bug fixes (and so there may be a 1.3.1, 1.3.2, etc), but new feature development will take place in Pyramid.
How do I get more help and support with Pyramid?
See Get Support.