Commit b1aba2bf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent db6c8a01
......@@ -114,14 +114,19 @@ class ZCtx(object):
zctx.root = zctx.zconn.root()
# init root['treegen/values'] = {} v -> ZBlk(v)
# TODO don't generate if already there
zctx.valdict = zctx.root['treegen/values'] = PersistentMapping()
valdict = zctx.root.get('treegen/values', None)
if valdict is None:
valdict = zctx.root['treegen/values'] = PersistentMapping()
valv = b'abcdefghi'
for v in valv:
zblk = valdict.get(v, None)
if zblk is not None and zblk.loadblkdata() == v:
continue
zblk = ZBlk()
zblk.setblkdata(v)
zctx.valdict[v] = zblk
commit('treegen/values: init %r' % valv)
valdict[v] = zblk
zctx.valdict = valdict
commit('treegen/values: init %r' % valv, skipIfEmpty=True)
# close release resources associated with zctx.
def close(zctx):
......@@ -343,11 +348,13 @@ def patch(d, diff, verify):
# commit commits current transaction with description.
def commit(description): # -> tid
def commit(description, skipIfEmpty=False): # -> tid | None
txn = transaction.get()
if skipIfEmpty and len(txn._resources) == 0:
return None
txn.description = description
# XXX hack to retrieve committed transaction ID via ._p_serial of object changed in this transaction
assert len(txn._resources) == 1
assert len(txn._resources) == 1, txn._resources
zconn = txn._resources[0]
assert isinstance(zconn, Connection)
assert len(zconn._registered_objects) > 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment