pyramid_cubicweb/__init__.py
changeset 11522 568204930c85
parent 11511 13e0f569684c
child 11532 6a1d0aa3ac85
equal deleted inserted replaced
11521:bf813ae7bf9d 11522:568204930c85
    30     config.include('pyramid_cubicweb.core')
    30     config.include('pyramid_cubicweb.core')
    31     config.include('pyramid_cubicweb.bwcompat')
    31     config.include('pyramid_cubicweb.bwcompat')
    32     return config
    32     return config
    33 
    33 
    34 
    34 
    35 def wsgi_application(instance_name=None, debug=None):
    35 def wsgi_application_from_cwconfig(cwconfig):
    36     if instance_name is None:
       
    37         instance_name = os.environ.get('CW_INSTANCE')
       
    38     if debug is None:
       
    39         debug = 'CW_DEBUG' in os.environ
       
    40 
       
    41     cwconfig = cwcfg.config_for(instance_name, debugmode=debug)
       
    42     config = make_cubicweb_application(cwconfig)
    36     config = make_cubicweb_application(cwconfig)
    43     app = config.make_wsgi_app()
    37     app = config.make_wsgi_app()
    44     # This replaces completely web/cors.py, which is not used by
    38     # This replaces completely web/cors.py, which is not used by
    45     # pyramid_cubicweb anymore
    39     # pyramid_cubicweb anymore
    46     app = wsgicors.CORS(
    40     app = wsgicors.CORS(
    48         origin=cwconfig['access-control-allow-origin'],
    42         origin=cwconfig['access-control-allow-origin'],
    49         headers=cwconfig['access-control-allow-headers'],
    43         headers=cwconfig['access-control-allow-headers'],
    50         methods=cwconfig['access-control-allow-methods'],
    44         methods=cwconfig['access-control-allow-methods'],
    51         credentials='true')
    45         credentials='true')
    52     return app
    46     return app
       
    47 
       
    48 
       
    49 def wsgi_application(instance_name=None, debug=None):
       
    50     if instance_name is None:
       
    51         instance_name = os.environ.get('CW_INSTANCE')
       
    52     if debug is None:
       
    53         debug = 'CW_DEBUG' in os.environ
       
    54 
       
    55     cwconfig = cwcfg.config_for(instance_name, debugmode=debug)
       
    56 
       
    57     return wsgi_application_from_cwconfig(cwconfig)