Edit me on GitHub

4: Quick Project Start With Scaffolds

Getting started quickly on a Python application requires, as we just saw, several steps. Like other popular web frameworks, Pyramid provides a facility called “scaffolds” that let you quickly generate the basics of a Pyramid application.

Objectives

  • Use pcreate to see what scaffolds are available
  • Create and install a sample project using one of the available scaffolds

Steps

  1. We don’t need to copy the previous step. Instead, just make an empty new directory:

    (env33)$ cd ..; mkdir step04; cd step04
    
  2. See the usage for pcreate:

    (env33)$ pcreate --help
    
  3. List the available scaffolds:

    (env33)$ pcreate --list
    
  4. Make a new Python project called tutorial using starter as a starting point:

    (env33)$ pcreate -s starter tutorial
    
  5. Visit that project and see the project contents:

    (env33)$ cd tutorial; ls
    
  6. Install your new project:

    (env33)$ python3.3 setup.py develop
    
  7. Run the WSGI application with:

    (env33)$ pserve development.ini
    
  8. Open http://127.0.0.1:6543/ in your browser. Different port number!

Analysis

Pyramid has a number of scaffold templates that provide different starting points. starter is the most basic. alchemy is useful for developers wanting SQLAlchemy as a starting point. These scaffolds provide a way for Pyramid to remain unopinionated, but still provide starting points with a set of opinions.

When you visited this project in your browser, you might have seen the pyramid_debugtoolbar in action. This is a handy helper during development.

Note

The remaining steps in this tutorial do not use scaffolds, as we want to teach the various decisions being made.

Extra Credit

  1. If you make a project with one of the scaffolds, can you still share your project with others?
  2. Can you make scaffolds for your own Pyramid projects?

Table Of Contents

Previous topic

3: Configuration Files and pserve

Next topic

5: Unit and Functional Tests