def checkPersistentIdHandlesDescriptor(self): from ZODB.serialize import ObjectWriter class P(Persistent): pass writer = ObjectWriter(None) self.assertEqual(writer.persistent_id(P), None)
def test_PersistentIdHandlesDescriptor(self): from ZODB.serialize import ObjectWriter class P(Persistent): pass writer = ObjectWriter(None) self.assertEqual(writer.persistent_id(P), None)
def persistent_id(self, obj): assert type(obj) is not Ghost oid = self.getOid(obj) if type(oid) is str: try: return self.oid_dict[oid] except KeyError: obj._p_activate() return ObjectWriter.persistent_id(self, obj)
def load_persistent(self, oid, klass): obj = ObjectReader.load_persistent(self, oid, klass) if self.oid_set is not None: if not self.lazy: self.oid_set.add(oid) obj._p_activate() self.oid_dict[oid] = oid_klass = ObjectWriter.persistent_id(self, obj) if oid_klass != (oid, klass): self.do_migrate = True return obj