cubicweb/pyramid/__init__.py
changeset 12052 1a1d2f5faddb
parent 12025 ba79f4a4f5d8
child 12079 4870e5a60a52
equal deleted inserted replaced
12051:bff3be6eebed 12052:1a1d2f5faddb
    18 # You should have received a copy of the GNU Lesser General Public License along
    18 # You should have received a copy of the GNU Lesser General Public License along
    19 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    19 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    20 
    20 
    21 """Pyramid interface to CubicWeb"""
    21 """Pyramid interface to CubicWeb"""
    22 
    22 
       
    23 import atexit
    23 import os
    24 import os
    24 from warnings import warn
    25 from warnings import warn
       
    26 
    25 import wsgicors
    27 import wsgicors
    26 
    28 
    27 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
    29 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
    28 from pyramid.config import Configurator
    30 from pyramid.config import Configurator
    29 from pyramid.exceptions import ConfigurationError
    31 from pyramid.exceptions import ConfigurationError
   222 
   224 
   223     if repo is None:
   225     if repo is None:
   224         repo = config.registry['cubicweb.repository'] = cwconfig.repository()
   226         repo = config.registry['cubicweb.repository'] = cwconfig.repository()
   225     config.registry['cubicweb.registry'] = repo.vreg
   227     config.registry['cubicweb.registry'] = repo.vreg
   226 
   228 
       
   229     atexit.register(repo.shutdown)
       
   230 
   227     if asbool(config.registry.settings.get('cubicweb.defaults', True)):
   231     if asbool(config.registry.settings.get('cubicweb.defaults', True)):
   228         config.include('cubicweb.pyramid.defaults')
   232         config.include('cubicweb.pyramid.defaults')
   229 
   233 
   230     for name in aslist(config.registry.settings.get('cubicweb.includes', [])):
   234     for name in aslist(config.registry.settings.get('cubicweb.includes', [])):
   231         config.include(name)
   235         config.include(name)