can change storage with set_storage, storage's name is store in storage object and storage is create with get_storage

This commit is contained in:
2013-08-25 20:49:24 +02:00
parent 36ed6f874f
commit dcb12dac02
5 changed files with 26 additions and 21 deletions

View File

@ -24,6 +24,8 @@ from tiramisu.i18n import _
class Storage(object):
__slots__ = tuple()
storage = 'dictionary'
def __init__(self, config_id, is_persistent):
if is_persistent:
raise ValueError(_('a dictionary cannot be persistent'))

View File

@ -25,6 +25,7 @@ import sqlite3
class Storage(object):
__slots__ = ('_conn', '_cursor', 'is_persistent', 'db_file')
storage = 'sqlite3'
def __init__(self, config_id, is_persistent):
self.is_persistent = is_persistent

View File

@ -70,12 +70,12 @@ class Values(Cache):
path = self._sqlite_encode_path(path)
self.storage.execute("DELETE FROM value WHERE path = ?", (path,))
def get_modified_values(self, context):
def get_modified_values(self):
"""return all values in a dictionary
example: {option1: (owner, 'value1'), option2: (owner, 'value2')}
"""
ret = {}
for path, value, owner in self.storage.select("SELECT value",
for path, value, owner in self.storage.select("SELECT * FROM value",
only_one=False):
path = self._sqlite_decode_path(path)
owner = getattr(owners, owner)