cannot change sqlite3 setting when connexion is already opened

This commit is contained in:
Emmanuel Garette 2019-02-22 08:45:22 +01:00
parent 4a737c5b9d
commit 0f78e6be77

View file

@ -22,6 +22,10 @@ import sqlite3
from ...error import ConflictError from ...error import ConflictError
global CONN
CONN = None
class Setting: class Setting:
""":param extension: database file extension (by default: db) """:param extension: database file extension (by default: db)
:param dir_database: root database directory (by default: /tmp) :param dir_database: root database directory (by default: /tmp)
@ -35,6 +39,12 @@ class Setting:
self.dir_database = '/tmp' self.dir_database = '/tmp'
self.name = 'tiramisu' self.name = 'tiramisu'
def __setattr__(self, key, value):
if CONN is not None:
raise Exception(_('cannot change setting when connexion is already '
'opened'))
super().__setattr__(key, value)
SETTING = Setting() SETTING = Setting()
@ -66,8 +76,6 @@ def delete_session(session_id,
CONN.commit() CONN.commit()
cursor.close() cursor.close()
global CONN
CONN = None
class Storage(object): class Storage(object):
__slots__ = ('_conn', '_cursor', 'persistent', 'session_id', 'session_name', 'created') __slots__ = ('_conn', '_cursor', 'persistent', 'session_id', 'session_name', 'created')