CherryPy Project Download

Storm is the ORM from Canonical (makers of Ubuntu.) Here is the simple implementation I have that utilizes CP 3.1 (Currently Beta) and Storms current trunk release.

For my connection setup, here is the code.

def connect_db(thread_index):
	database = create_database(cherrypy.config.get('storm.default.url'))
	cherrypy.thread_data.store = Store(database)
	
cherrypy.engine.subscribe('start_thread', connect_db)

In your config file you will want:

storm.default.url = "postgres://postgres:pass@server:5432/database"

Here is a sample method that uses genshi, storm etc:

@cherrypy.expose
@template.output('index.html')
def index(self, site_id=1):
    site = cherrypy.thread_data.store.find(Site, Site.site_id == 1).one()
    return template.render(site=site)

Hosted by WebFaction

Log in as guest/cherrypy to create/edit wiki pages