diff --git a/tiramisu/storage/sqlite3/storage.py b/tiramisu/storage/sqlite3/storage.py index 09eb2b4..897de6d 100644 --- a/tiramisu/storage/sqlite3/storage.py +++ b/tiramisu/storage/sqlite3/storage.py @@ -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')