import random class Query: """ Query represents the request from a user for information @type request_id: int """ #: @type: int probably unique identifier of this for long time request_id = None #: @type: string X{product_id} requested product_id = None def __init__(self): self.request_id = random.randint(100000,999999) self.product_id = None def __eq__(self, other): """ Equality based on product_id only @type other: Query @rtype: boolean @returns: True if both queries are for same product_id regardless of request_id's. False otherwise. """ if other == None: return False return self.product_id == other.product_id def __str__(self): return 'request_id:%s\nproduct_id:%s\n' % (str(self.request_id), str(self.product_id)) #class ProductIdQuery: # """ # ProductQuery is a L{Query} specifically on a single product_id # """ # #: X{product_id} requested (long) # product_id = None