pyramid_cubicweb/init_instance.py
author Philippe Pepiot <philippe.pepiot@logilab.fr>
Thu, 16 Jun 2016 16:25:32 +0200
changeset 11623 b6f6737d4823
parent 11492 b0b8942cdb80
permissions -rw-r--r--
wsgi: clearer exception when CW_INSTANCE is missing instance_name is mandatory for cwcfg.config_for() Raise with a KeyError: 'CW_INSTANCE' instead of hard to read exception.

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