def index(self, params): offset = params['offset'] limit = params['limit'] cursor = Photo.get_newests(self.root.db, offset, limit) query = dict(offset=offset, limit=limit) return royal.PaginatedResult(self, cursor, Item, query, cursor.count())
def index(self, query_params): offset = query_params["offset"] limit = query_params["limit"] cursor = Photo.get_newests(self.root.db, offset, limit, author=self.user.name) documents = [photos.Item(str(doc._id), self.root, self.request, doc).show() for doc in cursor] result = { "photos": documents, "href": self.url(offset=offset, limit=limit), "first": self.url(offset=0, limit=limit), } has_previous = offset > 0 if has_previous: result["previous"] = self.url(offset=max(offset - limit, 0), limit=limit) has_next = len(documents) == limit if has_next: result["next"] = self.url(offset=offset + limit, limit=limit) return result
def index(self, query_params): offset = query_params['offset'] limit = query_params['limit'] cursor = Photo.get_newests(self.root.db, offset, limit, author=self.parent.name) documents = [photos.Item(str(doc._id), self.root, doc).show() for doc in cursor] result = { 'photos': documents, 'href': self.url(offset=offset, limit=limit), 'first': self.url(offset=0, limit=limit), } has_previous = offset > 0 if has_previous: result['previous'] = self.url(offset=max(offset - limit, 0), limit=limit) has_next = len(documents) == limit if has_next: result['next'] = self.url(offset=offset + limit, limit=limit) return result
def index(self, query_params): offset = query_params['offset'] limit = query_params['limit'] cursor = Photo.get_newests(self.root.db, offset, limit, author=self.user.name) documents = [ photos.Item(str(doc._id), self.root, self.request, doc).show() for doc in cursor ] result = { 'photos': documents, 'href': self.url(offset=offset, limit=limit), 'first': self.url(offset=0, limit=limit), } has_previous = offset > 0 if has_previous: result['previous'] = self.url(offset=max(offset - limit, 0), limit=limit) has_next = len(documents) == limit if has_next: result['next'] = self.url(offset=offset + limit, limit=limit) return result
def index(self, offset, limit): cursor = Photo.get_newests(self.root.db, offset, limit, author=self.__parent__.__name__) query = dict(offset=offset, limit=limit) return royal.PaginatedResult(self, cursor, Resource, query, cursor.count())