middlestorm

Middleware for use Storm ORM in WSGI applications
Download

middlestorm Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL v2
  • Price:
  • FREE
  • Publisher Name:
  • Vsevolod Balashov
  • Publisher web site:
  • http://vsevolod.balashov.name

middlestorm Tags


middlestorm Description

Middleware for use Storm ORM in WSGI applications Storm is a fast, small and powerful object-relational mapper. Try it to use in web-aware applications.WSGI application mainly miltithreaded, but Store object is not thread safe.Middlestorm middleware can manage Store objects (one per thread) and add it into environ dictonary.Simple exampleThere are 3 ways to create middleware:* class* decorator* Paste configurationClass middleware:from wsgiref.simple_server import make_serverfrom storm.database import create_databasefrom middlestorm import MiddleStormdef storm_app(environ, start_response): store = environ # ...db = create_database('postgres://user:password@host/base')app = MiddleStorm(storm_app, db)make_server('', 8000, app).serve_forever()Decorator middleware:from wsgiref.simple_server import make_serverfrom storm.database import create_databaseimport middlestorm@middlestorm.decorator(create_database('postgres://user:password@host/base'))def storm_app(environ, start_response): store = environ # ...make_server('', 8000, storm_app).serve_forever()To create middleware via Paste configuration, add a stanza to the .ini file:use = middlestorm#middlestormdb_uri = sqlite:myapp.dband then add that filter to the Paste pipeline (again, in the .ini file):pipeline = middlestorm myappBy default Store placed in variable storm.store. This can be customized:app = MiddleStorm(storm_app, db, key='custom.mystore')or decorator style:@middlestorm.decorator(db, key='custom.mystore')def storm_app(environ, start_response): store = environor in the Paste configuration:use = middlestorm#middlestormdb_uri = sqlite:myapp.dbkey = myapp.storeor in the Paste configuration:use = middlestorm#middlestormdb_uri = sqlite:myapp.dbkey = myapp.store Requirements: · Python


middlestorm Related Software