예제 #1
0
 def relation_instances(self,
                        item,
                        attribute,
                        target_resource,
                        page=None,
                        per_page=None):
     query = getattr(item, attribute)
     if page and per_page:
         return Pagination.from_list(query, page, per_page)
     else:
         return query.all()
예제 #2
0
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        query = getattr(item, attribute)

        if isinstance(query, InstrumentedList):
            if page and per_page:
                return Pagination.from_list(query, page, per_page)
            return query

        if page and per_page:
            return self._query_get_paginated_items(query, page, per_page)

        return self._query_get_all(query)
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        query = getattr(item, attribute)

        if isinstance(query, InstrumentedList):
            if page and per_page:
                return Pagination.from_list(query, page, per_page)
            return query

        if page and per_page:
            return self._query_get_paginated_items(query, page, per_page)

        return self._query_get_all(query)
예제 #4
0
 def relation_instances(self,
                        item,
                        attribute,
                        target_resource,
                        page=None,
                        per_page=None):
     query = getattr(item, attribute)
     if page and per_page:
         # TODO see if this can be better done in one query
         return Pagination(query.paginate(page, per_page), page, per_page,
                           query.count())
     return query
예제 #5
0
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        collection = item.get(attribute, set())

        items = []
        for id in collection:
            try:
                items.append(target_resource.manager.read(id))
            except ItemNotFound:
                collection.remove(id)
                pass

        return Pagination.from_list(items, page, per_page)
예제 #6
0
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        collection = item.get(attribute, set())

        items = []
        for id in collection:
            try:
                items.append(target_resource.manager.read(id))
            except ItemNotFound:
                collection.remove(id)
                pass

        return Pagination.from_list(items, page, per_page)
예제 #7
0
 def paginated_instances_or(self,
                            page,
                            per_page,
                            where=None,
                            sort=None,
                            filter_or_cols=[],
                            filter_and_cols=[]):
     instances = self.instances_or(where=where,
                                   sort=sort,
                                   filter_or_cols=filter_or_cols,
                                   filter_and_cols=filter_and_cols)
     if isinstance(instances, list):
         return Pagination.from_list(instances, page, per_page)
     return self._query_get_paginated_items(instances, page, per_page)
예제 #8
0
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        query = getattr(item, attribute)

        if isinstance(query, InstrumentedList):
            if page and per_page:
                return Pagination.from_list(query, page, per_page)
            return query

        target_manager = target_resource.manager
        if isinstance(target_manager, PrincipalMixin):
            query = target_manager._query_filter_read_permission(query)

        if page and per_page:
            return target_manager._query_get_paginated_items(query, page, per_page)

        return target_manager._query_get_all(query)
예제 #9
0
    def relation_instances(self,
                           item,
                           attribute,
                           target_resource,
                           page=None,
                           per_page=None):
        query = getattr(item, attribute)

        if isinstance(query, InstrumentedList):
            if page and per_page:
                return Pagination.from_list(query, page, per_page)
            return query

        target_manager = target_resource.manager
        if isinstance(target_manager, PrincipalMixin):
            query = target_manager._query_filter_read_permission(query)

        if page and per_page:
            return target_manager._query_get_paginated_items(
                query, page, per_page)

        return target_manager._query_get_all(query)
예제 #10
0
 def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
     query = getattr(item, attribute)
     if page and per_page:
         return Pagination.from_list(query, page, per_page)
     else:
         return query.all()
예제 #11
0
 def paginated_instances(self, page, per_page, where=None, sort=None):
     query = self.instances(where, sort)
     # TODO see if this can be better done in one query
     return Pagination(query.paginate(page, per_page), page, per_page,
                       query.count())
예제 #12
0
파일: manager.py 프로젝트: infarm/potion
 def _paginate(self, items, page, per_page):
     return Pagination.from_list(list(items), page, per_page)
예제 #13
0
 def _paginate(self, items, page, per_page):
     return Pagination.from_list(list(items), page, per_page)