cubicweb/pyramid/__init__.py
branch3.24
changeset 11811 f09efeead7f9
parent 11702 be23c3813bbf
child 11958 950ce7d9f642
equal deleted inserted replaced
11810:2e03bb4372b2 11811:f09efeead7f9
    26     config = Configurator(settings=settings)
    26     config = Configurator(settings=settings)
    27     config.registry['cubicweb.config'] = cwconfig
    27     config.registry['cubicweb.config'] = cwconfig
    28     config.include('cubicweb.pyramid')
    28     config.include('cubicweb.pyramid')
    29     return config
    29     return config
    30 
    30 
       
    31 
    31 def settings_from_cwconfig(cwconfig):
    32 def settings_from_cwconfig(cwconfig):
    32     '''
    33     '''
    33     Extract settings from pyramid.ini and pyramid-debug.ini (if in debug)
    34     Extract settings from pyramid.ini and pyramid-debug.ini (if in debug)
    34 
    35 
    35     Can be used to configure middleware WSGI with settings from pyramid.ini files
    36     Can be used to configure middleware WSGI with settings from pyramid.ini files
    40     settings_filenames = [os.path.join(cwconfig.apphome, 'pyramid.ini')]
    41     settings_filenames = [os.path.join(cwconfig.apphome, 'pyramid.ini')]
    41     settings = {}
    42     settings = {}
    42     if cwconfig.debugmode:
    43     if cwconfig.debugmode:
    43         settings_filenames.insert(
    44         settings_filenames.insert(
    44             0, os.path.join(cwconfig.apphome, 'pyramid-debug.ini'))
    45             0, os.path.join(cwconfig.apphome, 'pyramid-debug.ini'))
    45     
    46 
    46         settings.update({
    47         settings.update({
    47             'pyramid.debug_authorization': True,
    48             'pyramid.debug_authorization': True,
    48             'pyramid.debug_notfound': True,
    49             'pyramid.debug_notfound': True,
    49             'pyramid.debug_routematch': True,
    50             'pyramid.debug_routematch': True,
    50             'pyramid.reload_templates': True,
    51             'pyramid.reload_templates': True,
    51         })
    52         })
    52     
    53 
    53     for fname in settings_filenames:
    54     for fname in settings_filenames:
    54         if os.path.exists(fname):
    55         if os.path.exists(fname):
    55             cp = SafeConfigParser()
    56             cp = SafeConfigParser()
    56             cp.read(fname)
    57             cp.read(fname)
    57             settings.update(cp.items('main'))
    58             settings.update(cp.items('main'))
    58             break
    59             break
    59     
    60 
    60     return settings
    61     return settings
    61 
    62 
    62 
    63 
    63 def wsgi_application_from_cwconfig(
    64 def wsgi_application_from_cwconfig(
    64         cwconfig,
    65         cwconfig,