author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Tue, 28 Jul 2009 23:49:47 +0200 | |
changeset 2545 | f8246ed962f6 |
parent 2476 | 1294a6bdf3bf |
child 2650 | 18aec79ec3a3 |
permissions | -rw-r--r-- |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
1 |
"""module defining the root handler for a lax instance. You should not have |
0 | 2 |
to change anything here. |
3 |
||
4 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
5 |
:copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 8 |
""" |
9 |
__docformat__ = "restructuredtext en" |
|
10 |
||
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
11 |
# compute instance's root directory |
0 | 12 |
from os.path import dirname, abspath |
13 |
APPLROOT = dirname(abspath(__file__)) |
|
14 |
||
15 |
# apply monkey patches first |
|
16 |
from cubicweb import goa |
|
17 |
goa.do_monkey_patch() |
|
18 |
||
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
19 |
# get instance's configuration (will be loaded from app.conf file) |
0 | 20 |
from cubicweb.goa.goaconfig import GAEConfiguration |
21 |
GAEConfiguration.ext_resources['JAVASCRIPTS'].append('DATADIR/goa.js') |
|
22 |
config = GAEConfiguration('toto', APPLROOT) |
|
23 |
||
24 |
# dynamic objects registry |
|
25 |
from cubicweb.goa.goavreg import GAERegistry |
|
26 |
vreg = GAERegistry(config, debug=goa.MODE == 'dev') |
|
27 |
||
28 |
# trigger automatic classes registration (metaclass magic), should be done |
|
29 |
# before schema loading |
|
30 |
import custom |
|
31 |
||
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
32 |
# load instance'schema |
0 | 33 |
vreg.schema = config.load_schema() |
34 |
||
35 |
# load dynamic objects |
|
36 |
vreg.load(APPLROOT) |
|
37 |
||
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
38 |
# call the postinit so custom get a chance to do instance specific stuff |
0 | 39 |
custom.postinit(vreg) |
40 |
||
41 |
from cubicweb.wsgi.handler import CubicWebWSGIApplication |
|
42 |
application = CubicWebWSGIApplication(config, vreg=vreg) |
|
43 |
||
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
44 |
# main function so this handler module is cached |
0 | 45 |
def main(): |
46 |
from wsgiref.handlers import CGIHandler |
|
47 |
CGIHandler().run(application) |
|
48 |
||
49 |
if __name__ == "__main__": |
|
50 |
main() |