author | Christophe de Vienne <christophe@unlish.com> |
Wed, 21 Jan 2015 15:13:43 +0100 | |
changeset 11545 | e83f90b1c900 |
parent 11540 | 10a1ee7836ed |
child 11547 | fd7d2033cd80 |
permissions | -rw-r--r-- |
11503
ddf61aa73384
Add a wsgi application factory suitable for wsgi servers.
Christophe de Vienne <christophe@unlish.com>
parents:
11501
diff
changeset
|
1 |
import os |
11511
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
2 |
import wsgicors |
11503
ddf61aa73384
Add a wsgi application factory suitable for wsgi servers.
Christophe de Vienne <christophe@unlish.com>
parents:
11501
diff
changeset
|
3 |
|
ddf61aa73384
Add a wsgi application factory suitable for wsgi servers.
Christophe de Vienne <christophe@unlish.com>
parents:
11501
diff
changeset
|
4 |
from cubicweb.cwconfig import CubicWebConfiguration as cwcfg |
11501
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
5 |
from pyramid.config import Configurator |
11534
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
6 |
from pyramid.settings import asbool, aslist |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
7 |
|
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
8 |
try: |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
9 |
from configparser import SafeConfigParser |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
10 |
except ImportError: |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
11 |
from ConfigParser import SafeConfigParser |
11501
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
12 |
|
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
13 |
|
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
14 |
def make_cubicweb_application(cwconfig): |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
15 |
""" |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
16 |
Create a pyramid-based CubicWeb instance from a cubicweb configuration. |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
17 |
|
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
18 |
It is initialy meant to be used by the 'pyramid' command of cubicweb-ctl. |
11537
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
19 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
20 |
:param cwconfig: A CubicWeb configuration |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
21 |
:returns: A Pyramid config object |
11501
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
22 |
""" |
11534
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
23 |
settings_filenames = [os.path.join(cwconfig.apphome, 'pyramid.ini')] |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
24 |
|
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
25 |
settings = {} |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
26 |
|
11501
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
27 |
if cwconfig.debugmode: |
11534
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
28 |
settings_filenames.insert( |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
29 |
0, os.path.join(cwconfig.apphome, 'pyramid-debug.ini')) |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
30 |
|
11501
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
31 |
settings.update({ |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
32 |
'pyramid.debug_authorization': True, |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
33 |
'pyramid.debug_notfound': True, |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
34 |
'pyramid.debug_routematch': True, |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
35 |
}) |
11534
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
36 |
|
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
37 |
for fname in settings_filenames: |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
38 |
if os.path.exists(fname): |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
39 |
cp = SafeConfigParser() |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
40 |
cp.read(fname) |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
41 |
settings.update(cp.items('main')) |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
42 |
break |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
43 |
|
11501
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
44 |
config = Configurator(settings=settings) |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
45 |
if cwconfig.debugmode: |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
46 |
config.include('pyramid_debugtoolbar') |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
47 |
config.registry['cubicweb.config'] = cwconfig |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
48 |
config.registry['cubicweb.repository'] = repo = cwconfig.repository() |
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
49 |
config.registry['cubicweb.registry'] = repo.vreg |
11534
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
50 |
|
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
51 |
if asbool(config.registry.settings.get('cubicweb.defaults', True)): |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
52 |
config.include('pyramid_cubicweb.defaults') |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
53 |
|
11540
10a1ee7836ed
Fix configuration loading when 'cubicweb.includes' is not set
Christophe de Vienne <christophe@unlish.com>
parents:
11537
diff
changeset
|
54 |
for name in aslist(config.registry.settings.get('cubicweb.includes', [])): |
11534
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
55 |
config.include(name) |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
56 |
|
11501
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
57 |
config.include('pyramid_cubicweb.core') |
11534
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
58 |
|
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
59 |
if asbool(config.registry.settings.get('cubicweb.bwcompat', True)): |
ceb1a5baca4f
[config] Read pyramid settings in a 'pyramid.ini' file
Christophe de Vienne <christophe@unlish.com>
parents:
11532
diff
changeset
|
60 |
config.include('pyramid_cubicweb.bwcompat') |
11501
fcf7f99fad4a
Add a make_cubicweb_application function
Christophe de Vienne <christophe@unlish.com>
parents:
11492
diff
changeset
|
61 |
return config |
11503
ddf61aa73384
Add a wsgi application factory suitable for wsgi servers.
Christophe de Vienne <christophe@unlish.com>
parents:
11501
diff
changeset
|
62 |
|
ddf61aa73384
Add a wsgi application factory suitable for wsgi servers.
Christophe de Vienne <christophe@unlish.com>
parents:
11501
diff
changeset
|
63 |
|
11535
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
64 |
def wsgi_application_from_cwconfig( |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
65 |
cwconfig, |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
66 |
profile=False, profile_output=None, profile_dump_every=None): |
11537
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
67 |
""" Build a WSGI application from a cubicweb configuration |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
68 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
69 |
:param cwconfig: A CubicWeb configuration |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
70 |
:param profile: Enable profiling. See :ref:`profiling`. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
71 |
:param profile_output: Profiling output filename. See :ref:`profiling`. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
72 |
:param profile_dump_every: Profiling number of requests before dumping the |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
73 |
stats. See :ref:`profiling`. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
74 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
75 |
:returns: A fully operationnal WSGI application |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
76 |
""" |
11503
ddf61aa73384
Add a wsgi application factory suitable for wsgi servers.
Christophe de Vienne <christophe@unlish.com>
parents:
11501
diff
changeset
|
77 |
config = make_cubicweb_application(cwconfig) |
11535
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
78 |
profile = profile or asbool(config.registry.settings.get( |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
79 |
'cubicweb.profile.enable', False)) |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
80 |
if profile: |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
81 |
config.add_route('profile_ping', '_profile/ping') |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
82 |
config.add_route('profile_cnx', '_profile/cnx') |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
83 |
config.scan('pyramid_cubicweb.profile') |
11511
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
84 |
app = config.make_wsgi_app() |
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
85 |
# This replaces completely web/cors.py, which is not used by |
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
86 |
# pyramid_cubicweb anymore |
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
87 |
app = wsgicors.CORS( |
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
88 |
app, |
11532
6a1d0aa3ac85
Fix cors 'origin' parameter passing
Christophe de Vienne <christophe@unlish.com>
parents:
11522
diff
changeset
|
89 |
origin=' '.join(cwconfig['access-control-allow-origin']), |
11511
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
90 |
headers=cwconfig['access-control-allow-headers'], |
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
91 |
methods=cwconfig['access-control-allow-methods'], |
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
92 |
credentials='true') |
11535
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
93 |
|
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
94 |
if profile: |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
95 |
from pyramid_cubicweb.profile import wsgi_profile |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
96 |
filename = profile_output or config.registry.settings.get( |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
97 |
'cubicweb.profile.output', 'program.prof') |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
98 |
dump_every = profile_dump_every or config.registry.settings.get( |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
99 |
'cubicweb.profile.dump_every', 100) |
dd875009cc47
[profile] Add a profiling tool
Christophe de Vienne <christophe@unlish.com>
parents:
11534
diff
changeset
|
100 |
app = wsgi_profile(app, filename=filename, dump_every=dump_every) |
11511
13e0f569684c
Use 'wsgicors' for CORS handling.
Christophe de Vienne <christophe@unlish.com>
parents:
11503
diff
changeset
|
101 |
return app |
11522
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
102 |
|
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
103 |
|
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
104 |
def wsgi_application(instance_name=None, debug=None): |
11537
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
105 |
""" Build a WSGI application from a cubicweb instance name |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
106 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
107 |
:param instance_name: Name of the cubicweb instance (optional). If not |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
108 |
provided, :envvar:`CW_INSTANCE` must exists. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
109 |
:param debug: Enable/disable the debug mode. If defined to True or False, |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
110 |
overrides :envvar:`CW_DEBUG`. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
111 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
112 |
The following environment variables are used if they exist: |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
113 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
114 |
.. envvar:: CW_INSTANCE |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
115 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
116 |
A CubicWeb instance name. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
117 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
118 |
.. envvar:: CW_DEBUG |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
119 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
120 |
If defined, the debugmode is enabled. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
121 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
122 |
The function can be used as an entry-point for third-party wsgi containers. |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
123 |
Below is a sample uswgi configuration file: |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
124 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
125 |
.. code-block:: ini |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
126 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
127 |
[uwsgi] |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
128 |
http = 127.0.1.1:8080 |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
129 |
env = CW_INSTANCE=myinstance |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
130 |
env = CW_DEBUG=1 |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
131 |
module = pyramid_cubicweb:wsgi_application() |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
132 |
virtualenv = /home/user/.virtualenvs/myvirtualenv |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
133 |
processes = 1 |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
134 |
threads = 8 |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
135 |
stats = 127.0.0.1:9191 |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
136 |
plugins = http,python |
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
137 |
|
caf268942436
Initial documentation.
Christophe de Vienne <christophe@unlish.com>
parents:
11535
diff
changeset
|
138 |
""" |
11522
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
139 |
if instance_name is None: |
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
140 |
instance_name = os.environ.get('CW_INSTANCE') |
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
141 |
if debug is None: |
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
142 |
debug = 'CW_DEBUG' in os.environ |
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
143 |
|
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
144 |
cwconfig = cwcfg.config_for(instance_name, debugmode=debug) |
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
145 |
|
568204930c85
Provides a full wsgi cubicweb application builder
Christophe de Vienne <christophe@unlish.com>
parents:
11511
diff
changeset
|
146 |
return wsgi_application_from_cwconfig(cwconfig) |