goa/skel/main.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 03 Aug 2009 10:50:57 +0200
changeset 2650 18aec79ec3a3
parent 2476 1294a6bdf3bf
child 4212 ab6573088b4a
permissions -rw-r--r--
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw

"""module defining the root handler for a lax instance. You should not have
to change anything here.

:organization: Logilab
:copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
__docformat__ = "restructuredtext en"

# compute instance's root directory
from os.path import dirname, abspath
APPLROOT = dirname(abspath(__file__))

# apply monkey patches first
from cubicweb import goa
goa.do_monkey_patch()

# get instance's configuration (will be loaded from app.conf file)
from cubicweb.goa.goaconfig import GAEConfiguration
GAEConfiguration.ext_resources['JAVASCRIPTS'].append('DATADIR/goa.js')
config = GAEConfiguration('toto', APPLROOT)

# dynamic objects registry
from cubicweb.goa.goavreg import GAEVregistry
vreg = GAEVregistry(config, debug=goa.MODE == 'dev')

# trigger automatic classes registration (metaclass magic), should be done
# before schema loading
import custom

# load instance'schema
vreg.schema = config.load_schema()

# load dynamic objects
vreg.load(APPLROOT)

# call the postinit so custom get a chance to do instance specific stuff
custom.postinit(vreg)

from cubicweb.wsgi.handler import CubicWebWSGIApplication
application = CubicWebWSGIApplication(config, vreg=vreg)

# main function so this handler module is cached
def main():
    from wsgiref.handlers import CGIHandler
    CGIHandler().run(application)

if __name__ == "__main__":
    main()