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
1 changed files with 10 additions and 2 deletions

View File

@ -22,6 +22,10 @@ import sqlite3
from ...error import ConflictError
global CONN
CONN = None
class Setting:
""":param extension: database file extension (by default: db)
:param dir_database: root database directory (by default: /tmp)
@ -35,6 +39,12 @@ class Setting:
self.dir_database = '/tmp'
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()
@ -66,8 +76,6 @@ def delete_session(session_id,
CONN.commit()
cursor.close()
global CONN
CONN = None
class Storage(object):
__slots__ = ('_conn', '_cursor', 'persistent', 'session_id', 'session_name', 'created')