Beispiel #1
0
 def check_oid_reuse(self):
     # Requires ShelfStorage oid reuse pack semantics
     s1 = ClientStorage(address=self.address)
     s1.oid_pool_size = 1
     c1 = Connection(s1)
     r1 = c1.get_root()
     s2 = ClientStorage(address=self.address)
     s2.oid_pool_size = 1
     c2 = Connection(s2)
     r2 = c2.get_root()
     r1['a'] = PersistentDict()
     r1['b'] = PersistentDict()
     c1.commit()
     c2.abort()
     a_oid = r1['a']._p_oid
     assert 'a' in r1 and 'b' in r1 and len(r1['b']) == 0
     assert 'a' in r2 and 'b' in r2 and len(r2['b']) == 0
     del r2['a'] # remove only reference to a
     c2.commit()
     c2.pack() # force relinquished oid back into availability
     sleep(0.5) # Give time for pack to complete
     c2.abort()
     assert c2.get(a_oid) is None
     c1.abort()
     assert c1.get(a_oid)._p_is_ghost()
     r2['b']['new'] = Persistent()
     r2['b']['new'].bogus = 1
     c2.commit()
     assert c2.get(a_oid) is r2['b']['new']
     c1.abort()
     assert c1.get(a_oid).__class__ == PersistentDict
     r1['b']['new'].bogus
     assert c1.get(a_oid).__class__ == Persistent
     s1.close()