Skip to main content

Set of paster templates for rapid Pyramid development

Project description

Introduction

khufu_opinion is a set of paster templates for rapid Pyramid development. It makes several framework choices for the developer which are:

  • Pyramid for the underlying web framework

    • traversal based url routing

  • Jinja2 for the page template language (similar to Django templates)

  • SQLAlchemy for ORM-based relational database persistence

Important URL’s

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

Command Runner

By default a new script named something-manage will be created in the bin 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

Paster

A development.ini file will be created inside the Something directory. This can be used with the standard paster commands:

# 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

Base Framework

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.

Templating

Any file ending with the .jinja2 extension located inside the 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 page called, main.jinja2.

Data Access

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 models.py Python file. The active database session can always be retrieved as the db attribute on the request object.

Transaction Support

Transactions are used to ensure all or nothing is performed. With the very useful pyramid_tm, repoze.tm2, and transaction packages this can be accomplished easily in Pyramid applications.

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.

Traversal

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 resources.py file.

Credits

  • Created and maintained by Rocky Burt (rocky AT serverzen DOT com)

Changes

0.5 - May 14, 2011

  • Now uses khufu_script

  • traversals module is now resources

0.2.2 - Feb 20, 2011

  • Renamed from RapidGiza to khufu_opinion

0.2.1 - Feb 16, 2011

  • Updated url’s to point to github repo

0.2 - Feb 5, 2011

  • switched from Werkzeug to Khufu-Script

  • now using Khufu-SQLAHelper

0.1.4 - Dec 1, 2010

  • yet another missing file (won’t happen again)

0.1.3 - Nov 30, 2010

  • Added yet another missing file to MANIFEST.in

0.1.2 - Nov 29, 2010

  • Changed make_app() signature

  • Added development.ini for out-of-the-box use with Paster serve

  • Generated projects now include two Paster apps

    1. <<project>>:app - Web app with included middleware

    2. <<project>>:pyramid-app - Web app without middleware

0.1.1 - Nov 29, 2010

  • Fixed MANIFEST.in so sdist contains appropriate files

0.1 - Nov 29, 2010

  • Initial version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

khufu_opinion-0.5.tar.gz (54.1 kB view details)

Uploaded Source

File details

Details for the file khufu_opinion-0.5.tar.gz.

File metadata

  • Download URL: khufu_opinion-0.5.tar.gz
  • Upload date:
  • Size: 54.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for khufu_opinion-0.5.tar.gz
Algorithm Hash digest
SHA256 3531da6c52ed37109414f16a279da5e8ba8d384e1a63ca028e331a59825ead4d
MD5 7c593efd6da3b322f7045739f95c63a5
BLAKE2b-256 9bf1da147250fcf1288fea37155266a50d8a46127e7837297e3bacb480b08a14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page