pyramid_cubicweb/__init__.py
changeset 11501 fcf7f99fad4a
parent 11492 b0b8942cdb80
child 11503 ddf61aa73384
equal deleted inserted replaced
11500:8e4935a1848b 11501:fcf7f99fad4a
       
     1 from pyramid.config import Configurator
       
     2 
       
     3 
       
     4 def make_cubicweb_application(cwconfig):
       
     5     """
       
     6     Create a pyramid-based CubicWeb instance from a cubicweb configuration.
       
     7 
       
     8     It is initialy meant to be used by the 'pyramid' command of cubicweb-ctl.
       
     9     """
       
    10     settings = {
       
    11         'session.secret': '11',  # XXX
       
    12     }
       
    13     if cwconfig.debugmode:
       
    14         settings.update({
       
    15             'pyramid.debug_authorization': True,
       
    16             'pyramid.debug_notfound': True,
       
    17             'pyramid.debug_routematch': True,
       
    18         })
       
    19     config = Configurator(settings=settings)
       
    20     if cwconfig.debugmode:
       
    21         config.include('pyramid_debugtoolbar')
       
    22     config.registry['cubicweb.config'] = cwconfig
       
    23     config.registry['cubicweb.repository'] = repo = cwconfig.repository()
       
    24     config.registry['cubicweb.registry'] = repo.vreg
       
    25     config.include('pyramid_cubicweb.defaults')
       
    26     config.include('pyramid_cubicweb.core')
       
    27     config.include('pyramid_cubicweb.bwcompat')
       
    28     return config