本文整理汇总了Python中durus.connection.Connection.get_storage方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.get_storage方法的具体用法?Python Connection.get_storage怎么用?Python Connection.get_storage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类durus.connection.Connection
的用法示例。
在下文中一共展示了Connection.get_storage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_storage_tools
# 需要导入模块: from durus.connection import Connection [as 别名]
# 或者: from durus.connection.Connection import get_storage [as 别名]
def check_storage_tools(self):
connection = Connection(self._get_storage())
root = connection.get_root()
root['a'] = Persistent()
root['b'] = Persistent()
connection.commit()
index = get_reference_index(connection.get_storage())
assert index == {
int8_to_str(1): [int8_to_str(0)], int8_to_str(2): [int8_to_str(0)]}
census = get_census(connection.get_storage())
assert census == {as_bytes('PersistentDict'):1, as_bytes('Persistent'):2}
references = list(gen_referring_oid_record(connection.get_storage(),
int8_to_str(1)))
assert references == [
(int8_to_str(0), connection.get_storage().load(int8_to_str(0)))]
class Fake(object):
pass
s = Fake()
s.__class__ = Storage
raises(RuntimeError, s.__init__)
raises(NotImplementedError, s.load, None)
raises(NotImplementedError, s.begin)
raises(NotImplementedError, s.store, None, None)
raises(NotImplementedError, s.end)
raises(NotImplementedError, s.sync)
g = s.gen_oid_record()
raises(NotImplementedError, next, g)
示例2: DurusFile
# 需要导入模块: from durus.connection import Connection [as 别名]
# 或者: from durus.connection.Connection import get_storage [as 别名]
class DurusFile(object):
def __init__(self, file, new):
self.__file = file
if new:
if os.path.exists(self.__file):
os.remove(self.__file)
self.__connection = Connection(FileStorage(self.__file))
self.__root = self.__connection.get_root()
def close(self):
self.__connection.get_storage().close()
def getBudget(self):
if self.__root.has_key("baseversion") and \
globalVars.baseversion == self.__root["baseversion"]:
return self.__root["budget"]
else:
print _("Incorrent Base version")
return None
def setBudget(self, budget):
self.__root["budget"] = budget
self.__root["baseversion"] = globalVars.baseversion
self.__connection.commit()