async def get_object_by_oid(oid, txn): """ Need to do a reverse lookup of the object to all the parents """ result = HARD_CACHE.get(oid, None) if result is None: result = await txn._get(oid) return await load_res(result, txn)
async def get_object(self, oid): if oid in self.cache: return self.cache[oid] try: result = self.txn._manager._hard_cache.get(oid, None) except AttributeError: from guillotina.db.transaction import HARD_CACHE # noqa result = HARD_CACHE.get(oid, None) if result is None: result = await self.txn._cache.get(oid=oid) if result is None: result = await self.tm._storage.load(self.txn, oid) obj = reader(result) obj._p_jar = self.txn if result['parent_id']: obj.__parent__ = await self.get_object(result['parent_id']) return obj