Posted by gldnspud on the 6th of December, 2006 at 2:27 pm under Uncategorized.    This post has no comments.

Note: This is based on development versions of the SchevoWsgi package.

SchevoWsgi provides an ability to expose one or more databases to a WSGI environment by way of a Paste filter called dbopener.

To use it in Pylons, first edit your development.ini file. Add these two sections below [DEFAULT], where yourapp is the unique name of your application:

[pipeline:main]
pipeline = dbopener yourapp

[filter:dbopener]
use = egg:SchevoWsgi#dbopener
schevo.db.db = %(here)s/dev.db
verbose = true

Change the [app:main] section name to [app:yourapp], to disambiguate it from the pipeline whose name is main.

Now, provided you have a dev.db Schevo database in the same directory as your development.ini file, it will open it when you serve up the development.ini application.

It is useful to expose the open database more easily by referring to self.db in controller code. To enable this, open yourapp/lib/base.py and add this line above the return statement in the BaseController.__call__ method:

self.db = environ['schevo.db.db']



* Required