本文整理汇总了Python中durus.connection.Connection.get_root()['A']方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.get_root()['A']方法的具体用法?Python Connection.get_root()['A']怎么用?Python Connection.get_root()['A']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类durus.connection.Connection
的用法示例。
在下文中一共展示了Connection.get_root()['A']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _scenario
# 需要导入模块: from durus.connection import Connection [as 别名]
# 或者: from durus.connection.Connection import get_root()['A'] [as 别名]
def _scenario(self):
c1 = Connection(self._get_storage())
c2 = Connection(self._get_storage())
c1.get_root()['A'] = Persistent()
c1.get_root()['B'] = Persistent()
c1.get_root()['A'].a = 1
c1.commit()
c2.abort()
c1.cache.recent_objects.discard(c1.get_root()['A'])
# Imagine c1 has been running for a while, and
# cache management, for example, has caused the
# cache reference to be weak.
return c1, c2
示例2: check_fine_conflict
# 需要导入模块: from durus.connection import Connection [as 别名]
# 或者: from durus.connection.Connection import get_root()['A'] [as 别名]
def check_fine_conflict(self):
c1 = Connection(self._get_storage())
c2 = Connection(self._get_storage())
c1.get_root()['A'] = Persistent()
c1.get_root()['A'].a = 1
c1.get_root()['B'] = Persistent()
c1.commit()
c2.abort()
# c1 has A loaded.
assert not c1.get_root()['A']._p_is_ghost()
c1.get_root()['B'].b = 1
c2.get_root()['A'].a = 2
c2.commit()
# Even though A has been changed by c2,
# c1 has not accessed an attribute of A since
# the last c1.commit(), so we don't want a ConflictError.
c1.commit()
assert c1.get_root()['A']._p_is_ghost()
c1.get_root()['A'].a # accessed!
c1.get_root()['B'].b = 1
c2.get_root()['A'].a = 2
c2.commit()
raises(WriteConflictError, c1.commit)