1
from pyscrabble import constants
2
from pyscrabble import manager
3
from ZODB import FileStorage, DB as _DB
13
Initialize the connection to the DB
15
r = manager.ResourceManager()
16
path = r["config"][constants.DB_LOCATION]
18
storage = FileStorage.FileStorage(path)
20
self._conn = db.open()
21
self._root = self._conn.root()
23
def __getattr__(self, key):
25
Retrive a key from the database
29
if key.startswith('_'):
30
return object.__getattr__(self, key)
32
if not self._root.has_key(key):
35
return self._root[key]
37
def __setattr__(self, key, value):
39
Add a key to the database
44
if key.startswith('_'):
45
object.__setattr__(self, key, value)
47
self._root[key] = value
49
def __delattr__(self, key):
51
Delete a key from the database
55
if key.startswith('_'):
56
object.__delattr__(self, key)
62
Commit any open transactions
64
self._root._p_changed = True
b'\\ No newline at end of file'