khufu_opinion is a set of paster templates for rapid Pyramid development. It makes several framework choices for the developer which are:
Setting up a New Project
Install khufu_opinion into a Python environment (ie virtualenv) with a working Paster. Once this has been done, you can create a new khufu_opinion project by simply running (where Something is the name of your new egg):
paster create -t khufu_starter Something
Once the template egg has been created you should set it up in develop mode to start working on your project.
cd Something python setup.py develop
Using the New Project
By default a new script named
something-manage will be created in the
directory of your python envionment. This script is a command
runner that provides the following:
Commands: runserver Run a reloadable development web server. loaddata Add data based on the YAML from filename shell Launch a Python shell syncdb Ensure all database tables exist
development.ini file will be created inside the Something
directory. This can be used with the standard
# use builtin paster http server paster serve development.ini
Deployment with Apache+mod_wsgi
There is a preconfigured
Something.wsgi file generated which
is necessary for plugging your app into a mod_wsgi environment.
A simple apache virtualhost entry will look like this:
<VirtualHost *:80> ServerName www.something.com WSGIScriptAlias / /path/to/Something.wsgi </VirtualHost>
Developing With the New Project
khufu_opinion is based on the Pyramid web application framework. As such, the Pyramid api will always be the go-to api for working with the web application. Please see the Pyramid docs for further details.
Any file ending with the
.jinja2 extension located inside
Something/something/templates directory will be rendered using
the Jinja2 templating system. This template language is
based on the Django templating language.
khufu_opinion produces two template files by default, one containing
the overall layout called,
layout.jinja2 and one for the default main
All data access is handled by the SQLAlchemy ORM framework which wraps relational databases. Out of the box, any new project created by khufu_opinion will have a SQLAlchemy database session factory setup.
khufu_opinion puts the orm model classes inside the
file. The active database session can always be retrieved as the
attribute on the
khufu_opinion ensures all requests join a new transaction so that if any error/exception occurs, the transaction is automatically rolled back. Any db sessions created via the provided session factory automatically join this transaction and will be rolled back in the event an error occurs.
The Pyramid web application framework provides a convenient mechanism
to traverse an object graph and map that graph to url's. khufu_opinion stores
it's traversal mechanism inside of the
- Created and maintained by Rocky Burt (rocky AT serverzen DOT com)