# HG changeset patch # User Christophe de Vienne # Date 1409233371 -7200 # Node ID ddf61aa73384d8520c47a7bd68671c9355cbb9b2 # Parent e4682c567e86117ddb293e7a32bc3c90658638d6 Add a wsgi application factory suitable for wsgi servers. This factory can generate a wsgi application for a cubicweb instance. It reads the instance name from the CW_INSTANCE environment variable, and activates the debugmode if CW_DEBUG is defined in environment. It is usable by uwsgi as the 'module' parameter : CW_INSTANCE=test uwsgi --plugins python,http --http 0.0.0.0:8080 --module pyramid_cubicweb:wsgi_application() diff -r e4682c567e86 -r ddf61aa73384 pyramid_cubicweb/__init__.py --- a/pyramid_cubicweb/__init__.py Wed Aug 27 19:26:44 2014 +0200 +++ b/pyramid_cubicweb/__init__.py Thu Aug 28 15:42:51 2014 +0200 @@ -1,3 +1,6 @@ +import os + +from cubicweb.cwconfig import CubicWebConfiguration as cwcfg from pyramid.config import Configurator @@ -26,3 +29,14 @@ config.include('pyramid_cubicweb.core') config.include('pyramid_cubicweb.bwcompat') return config + + +def wsgi_application(instance_name=None, debug=None): + if instance_name is None: + instance_name = os.environ.get('CW_INSTANCE') + if debug is None: + debug = 'CW_DEBUG' in os.environ + + cwconfig = cwcfg.config_for(instance_name, debugmode=debug) + config = make_cubicweb_application(cwconfig) + return config.make_wsgi_app()