The Big F'ing Tutorial: Development Using the repoze.bfg Web Framework

Are you a Python web developer who thinks there might be some great stuff hidden away in Zope but you consider it inaccessible to you because you feel that Zope imposes too many foreign concepts for your tastes? Are you a more-or-less happy Zope developer that has the nagging feeling that much of Zope is unnecessary "baggage" on your current project? Maybe you're a Plone developer who feels that Plone is unsuitable for one of your current projects because it's too complicated?

This tutorial will present everything you need to know about repoze.bfg, a small Python web framework in the spirit of Pylons. The goals of repoze.bfg are simplicity, familiarity to Zope programmers (but no Zope experience is required), execution speed, and complete, comprehensive, and up-to-date documentation.

In this tutorial, we'll explain the core concepts in repoze.bfg, then we'll lead a guided development session where we make a small application using the framework. We'll also cover packaging and deployment of the application. Questions are highly encouraged during the presentation.

Presenters

Chris McDonough is a principal and developer at Agendaless Consulting, a Python web development company. He is the primary author of repoze.bfg and much of the other Repoze software, as well as the Supervisor process controller. He has been writing Python web applications for nine years, and contributing to the development of Python web frameworks for eight years. He is a member of both the Zope Foundation and the Plone Foundation. He lives and works in Fredericksburg, VA, USA.

As a developer for the past 10 years, Chris Perkins has worked on everything from Joint Strike Fighter engine control test software to creating database applications for the National Renewable Energy Laboratory. He has been developing primarily with Python for the last 3 years and has contributed to numerous Open Source projects including Turbogears, SQLAlchemy, DBSprockets, and ToscaWidgets. He is an active member of the Front Range Pythoneers user group, and a Pycon attendee for the last 3 years. Please visit http://www.percious.com for more information about Chris Perkins.

Requirements

Attendees should bring a laptop. Attendees without an already-configured repoze.bfg development environment should bring a laptop with an already-installed repoze.bfg environment or a 32-bit Windows XP/Vista, x86 Linux, or Mac OS X Intel system with a DVD drive to participate in the guided development session. Users without an already-working repoze.bfg installation will be provided with to a VirtualBox virtual Linux environment on a DVD which will be made available during the tutorial. The presenters suggest coming in to the session with an already-configured machine, however.

Class Outline

First Half (Lecture): 1hr 30mins

  • Introduction, DVD handouts, Repoze history and repoze.bfg goals and comparisons with other Python web frameworks (5 minutes)
  • Describe an application package (10 minutes)
    • Describe the concept of an application as a Python "distribution" (setuptools).
  • Describe how repoze.bfg maps URLs to code (20 minutes)
    • Via graph traversal
      • Explain the concept of URL path segments as a graph traversal.
      • Describe the first repoze.bfg traversal example
    • Via URL dispatch
  • Describe "views" and templates (15 minutes)
    • Describe a view as a function that accepts a context and a request, and which returns a WebOb response and show an example.
    • Describe the chameleon.zpt templating language used as the default templating language within repoze.bfg.
    • Show the usage of a template called from within a view function.
  • Describe "models" (15 minutes)
    • As a persistent Python object graph
    • As Python objects created from data in a relational database
  • Describe repoze.bfg security features and ZCML (20 minutes)
    • ACLs
    • repoze.who
    • Configuring a security policy via ZCML
  • Pre-break Q & A and environment setup help registration (5 mins).

Break Period: 30 mins

Users with problems with the environment setup are encouraged to work through the break with the presenters. After the break, the guided development portion of the tutorial begins.

Second Half (Code-Along): 1 hr 15 mins

  • Installation and creating the project (10 minutes)

    • Creating a virtualenv
    • Installing repoze.bfg into the virtualenv
    • Using paster create -t bfg to create a project
    • Using setup.py develop to install the project into the virtualenv
  • Running the project (5 minutes).

    • Paster --reload feature.
    • Middleware configuration in config file.
    • paster serve myapp.ini.
  • Creating a model graph (20 minutes).

    • Creating a Wiki object (the "root")
    • Creating a WikiPage object
  • Modifying the run.py file. (5 minutes)

    • Set up the make_app function.
    • Start the application again.
  • Creating views and templates (30 minutes).

    • Creating a static resource view
    • Creating a root, page, and page_edit views and templates.
  • Securing your application (10 minutes)

    • Configure the RepozeWhoACLSecurityPolicy within ZCML.
    • Add permission declarations to views.
    • Configure repoze.who via who.ini and changes to app.ini.
    • View the application with and without the security policy in place.
  • Creating and running a test (5 minutes).

    • Creating a tests.py file and usage of setup.py test
  • Distributing the project (5 minutes).

    • Usage of setup.py sdist.

Diamond

  • White Oak Technologies Inc. - Diamond

Platinum

  • Google - Platinum
  • Sun - Platinum

Gold

  • ESRI - Gold
  • CCP Games - Gold
  • Visual Numerics, Inc. - Gold
  • Microsoft - Gold
  • Slide.com - Gold
  • Walt Disney Animation Studios - Gold

Silver

  • PSC Group - Silver
  • Enthought - Silver
  • Canonical - Silver
  • Imaginary Landscape - Silver
  • Wingware - Silver
  • ITA Software - Silver
  • Accense - Silver
  • Resolver Systems - Silver
  • Leapfrog Online - Silver
  • Emma Email Marketing - Silver
  • ZeOmega - Silver
  • Oracle Technology Network - Silver
  • VMware - Silver
  • Tummy.com - Silver

Vendor I

  • O'Reilly - Vendor I
  • Informit - Pearson Publishing - Vendor I