##// END OF EJS Templates
fixed problem with `Cannot operate on a closed database` error, by forcing NullPool when using sqlite database.
marcink -
r1300:882ac77d beta
parent child Browse files
Show More
@@ -6,18 +6,18 b' import logging'
6 from mako.lookup import TemplateLookup
6 from mako.lookup import TemplateLookup
7 from pylons.configuration import PylonsConfig
7 from pylons.configuration import PylonsConfig
8 from pylons.error import handle_mako_error
8 from pylons.error import handle_mako_error
9 from sqlalchemy import engine_from_config
10
9
11 import rhodecode.lib.app_globals as app_globals
10 import rhodecode.lib.app_globals as app_globals
12 import rhodecode.lib.helpers
11 import rhodecode.lib.helpers
13
12
14 from rhodecode.config.routing import make_map
13 from rhodecode.config.routing import make_map
15 from rhodecode.lib import celerypylons
14 from rhodecode.lib import celerypylons
15 from rhodecode.lib import engine_from_config
16 from rhodecode.lib.timerproxy import TimerProxy
16 from rhodecode.lib.auth import set_available_permissions
17 from rhodecode.lib.auth import set_available_permissions
17 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config
18 from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config
18 from rhodecode.model import init_model
19 from rhodecode.model import init_model
19 from rhodecode.model.scm import ScmModel
20 from rhodecode.model.scm import ScmModel
20 from rhodecode.lib.timerproxy import TimerProxy
21
21
22 log = logging.getLogger(__name__)
22 log = logging.getLogger(__name__)
23
23
@@ -79,3 +79,22 b" def safe_unicode(_str, from_encoding='ut"
79 u_str = unicode(_str, from_encoding, 'replace')
79 u_str = unicode(_str, from_encoding, 'replace')
80
80
81 return u_str
81 return u_str
82
83
84 def engine_from_config(configuration, prefix='sqlalchemy.', **kwargs):
85 """
86 Custom engine_from_config functions that makes sure we use NullPool for
87 file based sqlite databases. This prevents errors on sqlite.
88
89 """
90 from sqlalchemy import engine_from_config as efc
91 from sqlalchemy.pool import NullPool
92
93 url = configuration[prefix + 'url']
94
95 if url.startswith('sqlite'):
96 kwargs.update({'poolclass':NullPool})
97
98 return efc(configuration, prefix, **kwargs)
99
100
General Comments 0
You need to be logged in to leave comments. Login now