pyramid_cubicweb/__init__.py
changeset 11535 dd875009cc47
parent 11534 ceb1a5baca4f
child 11537 caf268942436
equal deleted inserted replaced
11534:ceb1a5baca4f 11535:dd875009cc47
    56     if asbool(config.registry.settings.get('cubicweb.bwcompat', True)):
    56     if asbool(config.registry.settings.get('cubicweb.bwcompat', True)):
    57         config.include('pyramid_cubicweb.bwcompat')
    57         config.include('pyramid_cubicweb.bwcompat')
    58     return config
    58     return config
    59 
    59 
    60 
    60 
    61 def wsgi_application_from_cwconfig(cwconfig):
    61 def wsgi_application_from_cwconfig(
       
    62         cwconfig,
       
    63         profile=False, profile_output=None, profile_dump_every=None):
    62     config = make_cubicweb_application(cwconfig)
    64     config = make_cubicweb_application(cwconfig)
       
    65     profile = profile or asbool(config.registry.settings.get(
       
    66         'cubicweb.profile.enable', False))
       
    67     if profile:
       
    68         config.add_route('profile_ping', '_profile/ping')
       
    69         config.add_route('profile_cnx', '_profile/cnx')
       
    70         config.scan('pyramid_cubicweb.profile')
    63     app = config.make_wsgi_app()
    71     app = config.make_wsgi_app()
    64     # This replaces completely web/cors.py, which is not used by
    72     # This replaces completely web/cors.py, which is not used by
    65     # pyramid_cubicweb anymore
    73     # pyramid_cubicweb anymore
    66     app = wsgicors.CORS(
    74     app = wsgicors.CORS(
    67         app,
    75         app,
    68         origin=' '.join(cwconfig['access-control-allow-origin']),
    76         origin=' '.join(cwconfig['access-control-allow-origin']),
    69         headers=cwconfig['access-control-allow-headers'],
    77         headers=cwconfig['access-control-allow-headers'],
    70         methods=cwconfig['access-control-allow-methods'],
    78         methods=cwconfig['access-control-allow-methods'],
    71         credentials='true')
    79         credentials='true')
       
    80 
       
    81     if profile:
       
    82         from pyramid_cubicweb.profile import wsgi_profile
       
    83         filename = profile_output or config.registry.settings.get(
       
    84             'cubicweb.profile.output', 'program.prof')
       
    85         dump_every = profile_dump_every or config.registry.settings.get(
       
    86             'cubicweb.profile.dump_every', 100)
       
    87         app = wsgi_profile(app, filename=filename, dump_every=dump_every)
    72     return app
    88     return app
    73 
    89 
    74 
    90 
    75 def wsgi_application(instance_name=None, debug=None):
    91 def wsgi_application(instance_name=None, debug=None):
    76     if instance_name is None:
    92     if instance_name is None: