forms are closely related to models

you'll need a way to persist the data.

if it's not tied to a specific directory of content, then it should probably be stored in a database of sorts to allow data lookup.

with pylons that probably means using sqlalchemy

if you didn't enable it in your project to begin with, you'll need to do so now following:
http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons

set up meta.py
set up model

init_model in __init

configure database string in config (development.ini)
sqlalchemy.url = sqlite:///%(here)s/jb-dev.sqlite

environment.py
websetup.py

don't forget!
paster setup-app development.ini


to start working with forms, you will new to methods to a class... one to show the form, one to handle the form.

you will also need to import the validate code. (formencode)

layouts and other form validation can be stored with other model code (I'm torn if that is more UI or model validation... pylons seems to go with model validation).

Pylons comes with an easy to use `validate` decorator, imported by default in your `lib/base.py`. Using it in your controller is pretty straight-forward:

#this gets the validate decorator.
from pylons.decorators import *



once you have a basic pylons instance created, there are a few things that need to be configured for most sites to get started.

This seems beyond the scope of a basic installation document, but nonetheless should be documented.

from root of project:

paster controller name-of-new-controller

start with a main controller:


for simple sites this may be enough. (i.e. sites with only one level deep)
for these sites it seems like over kill to make a separate controller for each page if there is really only an index page for each one.

some might argue to just stick with a templating system for a simple site, but just incase needs grow in the future, it is nice to have a framework in place. Pylons doesn't add a lot of bloat to even a simple site... so why not. Also keeps things consistent across projects.

make images and css directories in public:


remove public index.html (otherwise it will be default)


add standard templates

update routes