Change the future

Wednesday 9 a.m.–12:20 p.m.

Pyramid for Humans

Paul Everitt

Audience level:
Web Frameworks


Pyramid has emerged as a fast, modern, lightweight web framework. This lively, hands-on tutorial covers a little about a lot: practical introductions to the most common facilities. Fun, fast-paced, and most certainly not aimed at experts.



Humans! This is a tutorial for regular folks who know a bit about Python and web development.


A good, fun attitude. If you'd like to follow along with the material, a laptop with Python 2.6.x or higher and a good editor.

Update: See updated tutorial preparation instructions at Pyramid for Humans

Topics Covered

The tutorial will be presented in the context of the online "SQLAlchemy + URL Dispatch Wiki Tutorial" from the Pyramid website:

It will be a rewrite (and reduction) of the 2-day "Pyramid for Humans" tutorial at:

While the material will be reduced and the topic switched to Wiki+SQLAlchemy, the approach will be retained. Each "step" is an RST file, pointing at working code, installable as a package. This allows people to teleport themselves into the future if they get behind. Stated differently, attendees most likely can't fail.


  • Minor up front, lots of small steps

  • Each step has code with a working example (so people can teleport into future)

  • Each step has RST and links to the working package

  • Each step is a combination of intro, the code, explanation of the theory/purpose, and "extra credit" questions

Intro (10m)

  • What is this tutorial

  • Who is it for, not for

  • Objectives, what you should get out of it

  • What is and isn't Pyramid

  • Key features, strengths, weaknesses

  • About instructor

Python Setup (15m)

  • Python

  • Dependencies

  • virtualenv

  • Explain this tutorial's use of packages for each step

Installing Pyramid (10m)

  • easy_install pyramid

Hello World in Pyramid (15m)

  • Single file module, 21 lines

  • URL dispatch aka routes for view registration

  • Displays "hello world"

  • Extra Credit

  • Analysis

Hello World, Templates (15m)

  • Change from single module to:

  • Main module

  • with a default and named view

  • with the template

  • Use decorators and scanning to go find the views and register them

  • Extra credit

  • Analysis

Unit and Functional Testing (10m)

  • easy_install nose WebTest

  • A simple unit test and functional test

  • Show running the tests

  • Extra credit

  • Analysis

View Classes with Static Assets (10m)

  • Brief explanation of the what and why of view classes

  • Same as previous example, but done as a view class with 2 views

  • Include CSS and JS

  • Analysis

Interlude: Pyramid and Databases (5m)

  • Pyramid is not "batteries included"

  • Most Pyramid projects tend to use SQLAlchemy

Prepare for Wiki (10m)

  • Explain the sample application and its architecture

  • Install SQLite if needed and make sure your Python recognizes it

  • Install SQLAlchemy

  • Run simple command/module to verify setup

Basic Layout (15m)

  • INI file, resources, and views

  • Analysis

Extending the Resources (10m)

  • Show evolving the schema during development

  • Get the actual schema for a page in place

Views and Forms for Wiki (20m)

  • View classes, templates, and static assets

  • formalchemy for CRUD

Simple Authorization (15m)

  • Protect the editing with a login for users

  • For the tutorial, hardcoded username/password in INI file

Wrapup (10m)

  • Q&A