def request_content_by_date(self, oldestdatetime, newestdatetime=None, maxnumber=15): """Return a sequence of all ContentItems from the Service that fulfill the ContentRequest, newest first. oldestdatetime: A time-like object (datetime, date, struct_time, or tuple). No item will be returned as old or older. newestdatedate: A time-like object. No item will be returned as new or newer. Defaults to now. maxnumber: The maximum number of items to return. """ self.logger.info(str.format('Requesting content with oldest {0}, newest {1}, max {2}.', oldestdatetime, newestdatetime, maxnumber)) oldestdt = taoutils.create_datetime(oldestdatetime ) newestdt = taoutils.create_datetime(newestdatetime or datetime.datetime.now()) result = taoutils.take(self.db.get_between(oldestdt, newestdt), maxnumber) self.logger.info(str.format('Returning {0} items for request.', len(result))) return result
def request_content_slice(self, startindex=0, number=20): """Returns at most 'number' items, starting from 'startindex', newest items first.""" self.logger.info(str.format('Requesting item slice of size {0} from index {1} .', number, startindex)) result = taoutils.take(self.db.get_slice(startindex), number) self.logger.info(str.format('Returning {0} items.', len(result))) return result