diff options
| author | ianb <devnull@localhost> | 2005-05-14 23:12:45 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-14 23:12:45 +0000 |
| commit | 330dac21c0908b871fc73d9a17efefb7bd1e04be (patch) | |
| tree | a30f8371508bf8ff03d8a7ecfa2e28ba9b0dfd41 /examples/todo_wareweb/web/__init__.py | |
| parent | c5b9dee9b6ce25ff35a1a06858be781d07de294f (diff) | |
| download | paste-330dac21c0908b871fc73d9a17efefb7bd1e04be.tar.gz | |
Added Wareweb, a new framework. Yea for more frameworks\!
Diffstat (limited to 'examples/todo_wareweb/web/__init__.py')
| -rw-r--r-- | examples/todo_wareweb/web/__init__.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/todo_wareweb/web/__init__.py b/examples/todo_wareweb/web/__init__.py new file mode 100644 index 0000000..0fca385 --- /dev/null +++ b/examples/todo_wareweb/web/__init__.py @@ -0,0 +1,29 @@ +from paste.util import thirdparty +thirdparty.add_package('sqlobject') +import sqlobject +from todo_wareweb import db + +conns = {} + +def urlparser_hook(environ): + if not environ.has_key('todo_wareweb.base_url'): + environ['todo_wareweb.base_url'] = environ['SCRIPT_NAME'] + +def urlparser_wrap(environ, start_response, app): + db_uri = environ['paste.config']['database'] + first_conn = False + if db_uri in conns: + conn = conns[db_uri] + else: + first_conn = True + conns[db_uri] = conn = sqlobject.connectionForURI(db_uri) + sqlobject.sqlhub.threadConnection = conn + if first_conn: + db.check_db() + # @@: This doesn't allow for using database connections during + # the application iterator + try: + return app(environ, start_response) + finally: + sqlobject.sqlhub.threadConnection = None + |
