예제 #1
0
파일: localdb.py 프로젝트: toeb/client
    def _read_referenced_resources(self, query, id_type):
        statement = query

        ret = ReferencedResources()
        rs = statement.fetchall()
        cell_des = CellDeserializer(id_type)
        content_des = ContentDeserializer(id_type)
        for r in rs:
            try:
                v = Reference.deserialize(decode_serialized_value(r[0]))
                scontent = decode_serialized_value(r[2]) if r[2] else None
                res = Resource(cell_des.deserialize(decode_serialized_value(r[1])),
                               content_des.deserialize(scontent))
                cell_name = v.ref
                ret[v.block_version][cell_name] = res
                # logger.debug("Local found: %s/%s" % (str(v.block_version), str(cell_name)))
            except Exception as e:
                tb = traceback.format_exc()
                logger.error("Error while reading resources %s" % str(e))
                logger.debug(tb)

        return ret
예제 #2
0
 def testSerialize(self):
     serial = self.r.serialize()
     d = CellDeserializer(BlockCellName)
     deserialized = d.deserialize(serial)
     self.assertEquals(self.r, deserialized)