pyramid_cubicweb/init_instance.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 28 Jun 2016 11:03:20 +0200
changeset 11629 0459094d9728
parent 11492 b0b8942cdb80
permissions -rw-r--r--
Use opened connections as much as possible instead of opening a new internal connection to set the session cookie or retrieve the session data, which may exhaust the connection pools.

from cubicweb.cwconfig import CubicWebConfiguration


def includeme(config):
    appid = config.registry.settings['cubicweb.instance']
    cwconfig = CubicWebConfiguration.config_for(appid)

    config.registry['cubicweb.config'] = cwconfig
    config.registry['cubicweb.repository'] = repo = cwconfig.repository()
    config.registry['cubicweb.registry'] = repo.vreg