Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

115 lines (73 sloc) 2.595 kb

Step 04: Skeleton Views

Enough "hello world", now we start working on Projector. The UX person usually has a series of screens they need to prototype, mapping to a URL structure.

We want to make that process fast and productive.

In this step we mock up the structure of the site map:

/
/about.html
/acme
/people

...and make a series of URLs that implement these. Along the way, we make more views and more templates.

Goals

  • Introduce UX workflow of "screens" using dummy data

Objectives

  • "Default" and "named" views
  • More ZPT constructs

Steps

  1. $ cd ../../creatingux; mkdir step04; cd step04
  2. (Unchanged) Copy the following into step04/application.py:
  3. Copy the following into step04/views.py:
  4. Copy the following into step04/index.pt:
  5. Copy the following into step04/about.pt:
  6. Copy the following into step04/company.pt:
  7. Copy the following into step04/people.pt:
  8. Copy the following into step04/tests.py:
  9. $ nosetests should report running 6 tests.
  10. $ python application.py
  11. Open http://127.0.0.1:8080 in your browser.

Extra Credit

  1. What happens if you have two view registrations with no @name attribute, meaning both as the default?
  2. Is Chameleon (now at version 2) any better at showing you error messages? Give it a try, put some errors into your Python expressions.
  3. Will the WebTest correctly trigger that error?
  4. Does ending your URLs in .html have any effect?

Analysis

We are beginning the process of making a URL space that maps to objects and a hierarchy in our application. At the moment, we are simulating this with views.

Although our number of tests went up, each are still very small. Even such a simple test will still catch most of the silly errors that creep up during initial development. Hopefully you'll find that running nosetests is more productive than clickety-click.

Discussion

  • How do the registrations happen under the hood?
  • Chameleon, caching, and writing compiled versions to disk
Jump to Line
Something went wrong with that request. Please try again.