def find_by_id(self, item_id): result = store.find(self.__storage_name, key="id", value=item_id) if not result: return [] self.set_attributes(result[0]) return self
def search_items(cls, query): items=[] direction=None if 'lowtohigh' in query and query['lowtohigh']=="1": direction=ASCENDING if 'hightolow' in query and query['hightolow']=="1": print "YES" direction=DESCENDING query=cls.gen_query(query) for item in store.find(query).sort("price", direction): items.append(cls.modify(item)) return items
def get_all(cls): items=[] for item in store.find().sort("price"): items.append(cls.modify(item)) return items
def find_where(self, key, value): return store.find(self.__storage_name, key, value)