goa/skel/main.py
changeset 0 b97547f5f1fa
child 1802 d628defebc17
equal deleted inserted replaced
-1:000000000000 0:b97547f5f1fa
       
     1 """module defining the root handler for a lax application. You should not have
       
     2 to change anything here.
       
     3 
       
     4 :organization: Logilab
       
     5 :copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     7 """
       
     8 __docformat__ = "restructuredtext en"
       
     9 
       
    10 # compute application's root directory
       
    11 from os.path import dirname, abspath
       
    12 APPLROOT = dirname(abspath(__file__))
       
    13 
       
    14 # apply monkey patches first
       
    15 from cubicweb import goa
       
    16 goa.do_monkey_patch()
       
    17 
       
    18 # get application's configuration (will be loaded from app.conf file)
       
    19 from cubicweb.goa.goaconfig import GAEConfiguration
       
    20 GAEConfiguration.ext_resources['JAVASCRIPTS'].append('DATADIR/goa.js')
       
    21 config = GAEConfiguration('toto', APPLROOT)
       
    22 
       
    23 # dynamic objects registry
       
    24 from cubicweb.goa.goavreg import GAERegistry
       
    25 vreg = GAERegistry(config, debug=goa.MODE == 'dev')
       
    26 
       
    27 # trigger automatic classes registration (metaclass magic), should be done
       
    28 # before schema loading
       
    29 import custom
       
    30 
       
    31 # load application'schema
       
    32 vreg.schema = config.load_schema()
       
    33 
       
    34 # load dynamic objects
       
    35 vreg.load(APPLROOT)
       
    36 
       
    37 # call the postinit so custom get a chance to do application specific stuff
       
    38 custom.postinit(vreg)
       
    39 
       
    40 from cubicweb.wsgi.handler import CubicWebWSGIApplication
       
    41 application = CubicWebWSGIApplication(config, vreg=vreg)
       
    42 
       
    43 # main function so this handler module is cached 
       
    44 def main():
       
    45     from wsgiref.handlers import CGIHandler
       
    46     CGIHandler().run(application)
       
    47 
       
    48 if __name__ == "__main__":
       
    49     main()