paster serve --reload development.ini
view in firefox: | http://localhost:5000/
if no controller has been created, will get a 404
remove public index.html (otherwise it will be default) cd (package)/public #rm index.html bg.png pylons-logo.gif hg rm personnel/public/bg.png hg rm personnel/public/pylons-logo.gif hg rm personnel/public/index.html
#make images and css directories in public: cp -R /c/external/sites/charlesbrandt.com/templates/pylons/public/css public/ #import other default template files: cp -R /c/external/sites/charlesbrandt.com/templates/pylons/templates/* templates/ cp -R /c/external/sites/charlesbrandt.com/templates/pylons/controllers/* controllers/
#be sure to choose if you want the sqlalchemy version (model-sa) or non-sa: cp /c/external/sites/charlesbrandt.com/templates/pylons/model/* model/
update the imports in the controllers you plan to use
update lib/helpers.py to import webhelpers cp /c/external/sites/charlesbrandt.com/templates/pylons/lib/* lib/
sudo easy_install virtualenv
make sure model files have been created cp ../personnel-try1/personnel/model/__init__.py personnel/model/
paster setup-app development.ini
#make sure development.ini is using an open port: vi development.ini
update routes
python setup.py develop
virtualenv --no-site-packages personnel-virtual
cd personnel-virtual
source bin/activate
easy_install pylons easy_install formalchemy
paster create -t pylons_fa
cd personnel
hg init cp ../.hgignore .
hg add hg ci -m "new repo for new project"
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 add 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 *
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.
It may be adequate to stick with a template system (i.e. manual static, sphynx, webby) for a simple site. On the other hand, if you're comfortable with python and 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. A framework keeps things consistent across projects.