1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 """module defining the root handler for a lax instance. You should not have |
|
19 to change anything here. |
|
20 |
|
21 """ |
|
22 __docformat__ = "restructuredtext en" |
|
23 |
|
24 # compute instance's root directory |
|
25 from os.path import dirname, abspath |
|
26 APPLROOT = dirname(abspath(__file__)) |
|
27 |
|
28 # apply monkey patches first |
|
29 from cubicweb import goa |
|
30 goa.do_monkey_patch() |
|
31 |
|
32 # get instance's configuration (will be loaded from app.conf file) |
|
33 from cubicweb.goa.goaconfig import GAEConfiguration |
|
34 GAEConfiguration.uiprops['JAVASCRIPTS'].append('DATADIR/goa.js') |
|
35 config = GAEConfiguration('toto', APPLROOT) |
|
36 |
|
37 # dynamic objects registry |
|
38 from cubicweb.goa.goavreg import GAEVregistry |
|
39 vreg = GAEVregistry(config, debug=goa.MODE == 'dev') |
|
40 |
|
41 # trigger automatic classes registration (metaclass magic), should be done |
|
42 # before schema loading |
|
43 import custom |
|
44 |
|
45 # load instance'schema |
|
46 vreg.schema = config.load_schema() |
|
47 |
|
48 # load dynamic objects |
|
49 vreg.load(APPLROOT) |
|
50 |
|
51 # call the postinit so custom get a chance to do instance specific stuff |
|
52 custom.postinit(vreg) |
|
53 |
|
54 from cubicweb.wsgi.handler import CubicWebWSGIApplication |
|
55 application = CubicWebWSGIApplication(config, vreg=vreg) |
|
56 |
|
57 # main function so this handler module is cached |
|
58 def main(): |
|
59 from wsgiref.handlers import CGIHandler |
|
60 CGIHandler().run(application) |
|
61 |
|
62 if __name__ == "__main__": |
|
63 main() |
|