Personal tools
Contact Us 24/7 > 1 866.SIX FEET
Sections

Skip to content. | Skip to navigation

Home > Blog > Intro to the Python Framework Pyramid

DjangoCourseBanner.jpg

Blog

Intro to the Python Framework Pyramid

written by Calvin Hendryx-Parker on Tuesday February 26, 2013

We pyramidwebframework_logo.pngprefer Pyramid to Django, Flask, and Bottle due to its flexibility, scalability and speed. It gives us more control than Django and is easy to create a small app that can scale later without being rewritten. These are many of the same reasons for Why We Choose Python in general.

Recently we provided some training on how Pyramid works that was recorded. It provides a great overview of why Pyramid is ideal and how to setup a basic app with scaffolds, routes, and persistence. We also built a ToDo App for a web shootout we organized in Indianapolis through IndyPy. Putting these together turned out to be a great introduction to Pyramid, so I wrote this post.

To get a good understanding of the Pyramid framework and see how to implement a basic ToDo app from scratch:

  1. Watch our Intro to Pyramid video below (21 min)
  2. Play with the ToDo app demo at http://demo.todo.sixfeetup.com/
  3. Read the step by step instructions in the ToDo app README.md at https://github.com/indypy/todopyramid
  4. Checkout the official documentation and tutorials at http://docs.pylonsproject.org/en/latest/docs/pyramid.html

If you would like to discuss Six Feet Up building your next web application, contact us or signup for our newsletter to get more articles like this.

If you are looking for a an in depth comparison of Pyramid vs. other frameworks check out Why We Choose Pyramid for Rapid Web Development Projects.

Here are some key points from the video:

General Info

Pyramid is a Python based open source web framework. According to the project's website:

As a framework, its primary job is to make it easier for a developer to create an arbitrary web application. The type of application being created isn’t really important; it could be a spreadsheet, a corporate intranet, or a social networking platform. Pyramid is general enough that it can be used in a wide variety of circumstances.

The Pyramid tenets are:

  • Simplicity
  • Minimalism
  • Documentation
  • Speed
  • Reliability
  • Openness

Pyramid is based on Zope, Pylons, and Django. It supports small and large projects so there is no need to rewrite like you would with small frameworks. It's also the fastest Python web framework.

The Pyramid Configuration Supports:

  • imperative configuration
  • conflict detection
  • extensibility
  • flexible authentication and authorization policies
  • programmatic introspection

Scaffolding and Templating

Pyramid comes with several basic scaffolds to get you started and lets you pick your preferred templating system. Chameleon, Mako, Jinja 2 and others are supported.

Persistence

Pyramid lets you pick whatever persistence method you prefer and supports ZODB and SQLAlchemy. You could also use MongoDB, PostgreSQL and others.

Additional Resources

Pyramid 1.4 Docs - http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/
Pyramid Denials - http://docs.pylonsproject.org/en/latest/denials/pyramid.html

Want to learn more about Pyramid?

 
Posted by J on Mar 07, 2013 11:32 AM
"Tenets" not "Tenants." Thanks very much for the post! I've been using Django and Flask but had never really gotten around to learning about Pyramid.
Posted by Paul Whipp on Mar 24, 2013 09:57 PM
This is more for https://github.com/indypy/todopyramid#readme but can't comment there and this implies it can be followed through: I'm working on Ubuntu 10.04LTS: First try of "pserve production.ini" yielded "pkg_resources.DistributionNotFound: waitress" "pip install waitress" seemed to deal with that but then I got "pkg_resources.DistributionNotFound: todopyramid" So I gave "setup.py install" a go since that seemed a logical precursor to using the project. Once that is done, "pserve production.ini" works although it reports: "/home/paul/virtualenv/pyramid/lib/python2.6/site-packages/deform-0.9.7-py2.6.egg/deform/__init__.py:9: DeprecationWarning: Set: deform.Set is deprecated as of the release of Colander > 1.0a1, which includes its own Set class. colander.Set is not exactly a drop-in replacement (it has no allow_empty constructor argument), but you should switch to it as soon as possible. The deform.Set class will be removed in Deform 1.1+ from .schema import Set # API Adding asdict2() to Colander. " Documentation needs to include both these steps - you are probably haemoragging potential users without them.
Posted by Calvin Hendryx-Parker on Mar 24, 2013 10:10 PM
I'll forward this on to Clayton to make sure he updates the docs as needed.
Posted by Clayton Parker on Mar 24, 2013 11:06 PM
The version of "bag" that was pinned in the requirements.txt had gone away. This caused the pip command to fail, and thus stopped processing requirements (waitress among them). I pinned bag to 0.3.2, which is on pypi, now the pip install command works properly. You'll need to pull in the latest code first. I also updated the install docs with the missing database initialization step. If you have any further problems, you can report them on the issue tracker of the app here: https://github.com/indypy/todopyramid/issues
Posted by Markus Smith on Jun 06, 2013 11:01 AM
Please, add the link to the mentioned video.
Posted by clayton on Jun 12, 2013 07:16 PM
I fixed the embed of the video in the page. Thanks for pointing out it was missing!
Add comment

You can add a comment by filling out the form below. Plain text formatting.

puzzle

Next Steps


Select a type of support:

Contact our sales team

First Name:  
Last Name:  
Email Address:  
Phone Number:
Message:  
Fight spam:
What is + ?  
 
Call Us 1 866.SIX FEET
Sections