class Response: #: @type: int should match associated L{Query}.request_id request_id = None #: @type: Node node = None #: @type: dict from L{upcdatabase} upcdb_dict = None #:@type: found_node_in_tam: bool found_node_in_tam = False #: @type: found_product_in_upcdb: bool found_product_in_upcdb = False def __eq__(self, other): """ @type other: L{Response} @rtype: boolean @returns: True if all fields except L{request_id} are equivalent. False otherwise. """ if other == None: return False return self.node == other.node and \ self.upcdb_dict == other.upcdb_dict and \ self.found_node_in_tam == other.found_node_in_tam and \ self.found_product_in_upcdb == other.found_product_in_upcdb def weak_eq(self, other): """ @type other: L{Response} @rtype: boolean @returns: True if all fields except L{request_id} and L{node} are equivalent. L{node} equivalence is checked on node.label only. False otherwise. """ if other == None: return False # to prevent Null dereference later, check node lables now if self.node == None or other.node == None: if self.node != None or other.node != None: return False elif self.node.label != other.node.label: return False return self.upcdb_dict == other.upcdb_dict and \ self.found_node_in_tam == other.found_node_in_tam and \ self.found_product_in_upcdb == other.found_product_in_upcdb def __init__(self, req_id): self.request_id = req_id self.node = None self.upcdb_dict = None self.found_node_in_tam = False self.found_product_in_upcdb = False def __str__(self): return 'request_id:%s\nfound_node_in_tam:%s\nfound_product_in_upcdb:%s\nnode:%s\nupcdb_dict:%s\n' % (str(self.request_id), str(self.found_node_in_tam), str(self.found_product_in_upcdb), str(self.node), str(self.upcdb_dict))