pyramid_cubicweb/init_instance.py
author Rabah Meradi <rabah.meradi@logilab.fr>
Mon, 15 Jun 2015 09:31:37 +0200
changeset 11598 2dc0b0db2329
parent 11492 b0b8942cdb80
permissions -rw-r--r--
use CubicWeb request to execute RQL rset should be retrieved with cw_request, as it's then bound to it and propagate to all entities created from this rset (._cw). From there it may reach code expecting a request, not a connection (view, selector, etc).

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