cubicweb/pyramid/__init__.py
changeset 11958 950ce7d9f642
parent 11811 f09efeead7f9
child 11959 ddc05ce75319
equal deleted inserted replaced
11957:48b8fbc88209 11958:950ce7d9f642
    10     from configparser import SafeConfigParser
    10     from configparser import SafeConfigParser
    11 except ImportError:
    11 except ImportError:
    12     from ConfigParser import SafeConfigParser
    12     from ConfigParser import SafeConfigParser
    13 
    13 
    14 
    14 
    15 def make_cubicweb_application(cwconfig, settings=None):
    15 def config_from_cwconfig(cwconfig, settings=None):
    16     """
    16     """Return a Pyramid Configurator instance built from a CubicWeb config and
    17     Create a pyramid-based CubicWeb instance from a cubicweb configuration.
    17     Pyramid-specific configuration files (pyramid.ini).
    18 
       
    19     It is initialy meant to be used by the 'pyramid' command of cubicweb-ctl.
       
    20 
    18 
    21     :param cwconfig: A CubicWeb configuration
    19     :param cwconfig: A CubicWeb configuration
    22     :returns: A Pyramid config object
    20     :returns: A Pyramid config object
    23     """
    21     """
    24     settings = dict(settings) if settings else {}
    22     settings = dict(settings) if settings else {}
    72     :param profile_dump_every: Profiling number of requests before dumping the
    70     :param profile_dump_every: Profiling number of requests before dumping the
    73                                stats. See :ref:`profiling`.
    71                                stats. See :ref:`profiling`.
    74 
    72 
    75     :returns: A fully operationnal WSGI application
    73     :returns: A fully operationnal WSGI application
    76     """
    74     """
    77     config = make_cubicweb_application(cwconfig)
    75     config = config_from_cwconfig(cwconfig)
    78     profile = profile or asbool(config.registry.settings.get(
    76     profile = profile or asbool(config.registry.settings.get(
    79         'cubicweb.profile.enable', False))
    77         'cubicweb.profile.enable', False))
    80     if profile:
    78     if profile:
    81         config.add_route('profile_ping', '_profile/ping')
    79         config.add_route('profile_ping', '_profile/ping')
    82         config.add_route('profile_cnx', '_profile/cnx')
    80         config.add_route('profile_cnx', '_profile/cnx')