# Path: pyston/exception.py
# class RestException(Exception):
#     message = None
# 
#     def __init__(self, message=None):
#         super().__init__()
#         self.message = message or self.message
# 
#     @property
#     def errors(self):
#         return {'error': self.message}
# 
# Path: pyston/paginator.py
# class BasePaginator:
# 
#     def get_response(self, qs, request):
#         raise NotImplementedError
# 
# Path: pyston/response.py
# class HeadersResponse:
# 
#     fieldset = True
# 
#     def __init__(self, result, http_headers=None, code=200):
#         http_headers = {} if http_headers is None else http_headers
#         self.result = result
#         self.http_headers = http_headers
#         self.status_code = code


import base64
import json
from django.utils.translation import ugettext
from pyston.exception import RestException
from pyston.paginator import BasePaginator
from pyston.response import HeadersResponse




class DynamoCursorBasedPaginator(BasePaginator):

    def __init__(self, default_base=20, max_base=100):
        self.default_base = default_base
        self.max_base = max_base

    def get_response(self, qs, request):
        base = self._get_base(request)
        cursor = self._get_cursor(request)

        if cursor is not None:
            qs = qs.set_last_evaluated_key(cursor)
        qs = qs.set_limit(base)


# Path: pyston/exception.py
# class RestException(Exception):
#     message = None
# 
#     def __init__(self, message=None):
#         super().__init__()
#         self.message = message or self.message
# 
#     @property
#     def errors(self):
#         return {'error': self.message}
# 
# Path: pyston/paginator.py
# class BasePaginator:
# 
#     def get_response(self, qs, request):
#         raise NotImplementedError
# 
# Path: pyston/response.py
# class HeadersResponse:
# 
#     fieldset = True
# 
#     def __init__(self, result, http_headers=None, code=200):
#         http_headers = {} if http_headers is None else http_headers
#         self.result = result
#         self.http_headers = http_headers
#         self.status_code = code


# Path: pyston/contrib/dynamo/paginator.py
import base64
import json
from django.utils.translation import ugettext
from pyston.exception import RestException
from pyston.paginator import BasePaginator
from pyston.response import HeadersResponse





class DynamoCursorBasedPaginator(BasePaginator):

    def __init__(self, default_base=20, max_base=100):
        self.default_base = default_base
        self.max_base = max_base

    def get_response(self, qs, request):
        base = self._get_base(request)
        cursor = self._get_cursor(request)

        if cursor is not None:
            qs = qs.set_last_evaluated_key(cursor)
        qs = qs.set_limit(base)


        return HeadersResponse(