# Path: seth/classy/base.py
# class QuerySetMixin(object):
#     model = None
#     paginate = True
#     filter_class = None
#     lookup_param = u'id'
# 
#     def get_model(self):
#         raise NotImplementedError
# 
#     def get_queryset(self, *args, **kwargs):
#         raise NotImplementedError
# 
#     def filter_queryset(self, qs):
#         if self.filter_class:
#             filter_instance = self.filter_class(qs)
#             return filter_instance.apply(self.request)
# 
#         return qs
# 
#     def paginate_queryset(self, qs):
#         settings = self.request.registry.settings
# 
#         page_param = settings.get('pagination.page_param_name', 'page')
#         default_page = settings.get('pagination.default_page', 1)
#         per_page_param = settings.get('pagination.per_page_param_name', 'per_page')
#         default_per_page = settings.get('pagination.default_per_page', 20)
# 
#         try:
#             page = int(self.request.params.get(page_param, default_page))
#         except ValueError:
#             page = default_page
# 
#         try:
#             per_page = int(self.request.params.get(per_page_param, default_per_page))
#         except ValueError:
#             per_page = default_per_page
# 
#         return paginate(qs, page, per_page)


from pyramid.response import Response
from pyramid.httpexceptions import HTTPNotImplemented, HTTPOk
from seth.classy.base import QuerySetMixin



class ExportResource(QuerySetMixin):
    template = None
    export_factory = None

    def __init__(self, request):
        self.request = request

    def get_queryset(self, *args, **kwargs):
        return None

    def run_exporter(self):
        if not self.template:
            raise HTTPNotImplemented(u"Template not configured")

        qs = self.get_queryset()
        # if no queryset is predefined export
        qs = qs if qs is not None else self.export_factory.model.query
        # filters queryset - has request access so it can be used to filer
        # or optionaly filter_class can be specified

# Path: seth/classy/base.py
# class QuerySetMixin(object):
#     model = None
#     paginate = True
#     filter_class = None
#     lookup_param = u'id'
# 
#     def get_model(self):
#         raise NotImplementedError
# 
#     def get_queryset(self, *args, **kwargs):
#         raise NotImplementedError
# 
#     def filter_queryset(self, qs):
#         if self.filter_class:
#             filter_instance = self.filter_class(qs)
#             return filter_instance.apply(self.request)
# 
#         return qs
# 
#     def paginate_queryset(self, qs):
#         settings = self.request.registry.settings
# 
#         page_param = settings.get('pagination.page_param_name', 'page')
#         default_page = settings.get('pagination.default_page', 1)
#         per_page_param = settings.get('pagination.per_page_param_name', 'per_page')
#         default_per_page = settings.get('pagination.default_per_page', 20)
# 
#         try:
#             page = int(self.request.params.get(page_param, default_page))
#         except ValueError:
#             page = default_page
# 
#         try:
#             per_page = int(self.request.params.get(per_page_param, default_per_page))
#         except ValueError:
#             per_page = default_per_page
# 
#         return paginate(qs, page, per_page)


# Path: seth/classy/web/export.py
from pyramid.response import Response
from pyramid.httpexceptions import HTTPNotImplemented, HTTPOk
from seth.classy.base import QuerySetMixin




class ExportResource(QuerySetMixin):
    template = None
    export_factory = None

    def __init__(self, request):
        self.request = request

    def get_queryset(self, *args, **kwargs):
        return None

    def run_exporter(self):
        if not self.template:
            raise HTTPNotImplemented(u"Template not configured")

        qs = self.get_queryset()
        # if no queryset is predefined export
        qs = qs if qs is not None else self.export_factory.model.query
        # filters queryset - has request access so it can be used to filer
        # or optionaly filter_class can be specified

        qs = self.filter_queryset(qs)