Make rattail config object use our scoped session, when consulting db.

Whoops, apparently we were previously creating a new session for each
config check?  Hopefully this helps...
This commit is contained in:
Lance Edgar 2016-02-08 19:45:06 -06:00
parent 74a13fb739
commit 6c8425b06d

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2015 Lance Edgar
# Copyright © 2010-2016 Lance Edgar
#
# This file is part of Rattail.
#
@ -24,7 +24,7 @@
Application Entry Point
"""
from __future__ import unicode_literals
from __future__ import unicode_literals, absolute_import
import os
import logging
@ -87,6 +87,10 @@ def make_rattail_config(settings):
rattail.db.Session.configure(bind=rattail_engines['default'])
tailbone.db.Session.configure(bind=rattail_engines['default'])
# Make sure rattail config object uses our scoped session, to avoid
# unnecessary connections (and pooling limits).
rattail_config._session_factory = lambda: (tailbone.db.Session(), False)
# Configure (or not) Continuum versioning.
configure_versioning(rattail_config)
return rattail_config