# Path: pydal/_compat.py
# PY2 = sys.version_info[0] == 2
#     def implements_bool(cls):
#     def implements_iterator(cls):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def to_unicode(obj, charset="utf-8", errors="strict"):
#     class metaclass(meta):


import datetime
import decimal
import json as jsonlib
from .._compat import PY2, integer_types
            from yaml import dump
    _custom_ = {}

    def _json_parse(self, o):
        if hasattr(o, "custom_json") and callable(o.custom_json):
            return o.custom_json()
        if isinstance(o, (datetime.date, datetime.datetime, datetime.time)):
            return o.isoformat()[:19].replace("T", " ")
        elif isinstance(o, long):
            return int(o)
        elif isinstance(o, decimal.Decimal):
            return str(o)
        elif isinstance(o, set):
            return list(o)
        elif hasattr(o, "as_list") and callable(o.as_list):
            return o.as_list()
        elif hasattr(o, "as_dict") and callable(o.as_dict):
            return o.as_dict()
        if self._custom_.get("json") is not None:
            return self._custom_["json"](o)
        raise TypeError(repr(o) + " is not JSON serializable")

    def __getattr__(self, name):
        if self._custom_.get(name) is not None:
            return self._custom_[name]
        raise NotImplementedError("No " + str(name) + " serializer available.")

    def json(self, value):
        value = jsonlib.dumps(value, default=self._json_parse)
        rep28 = r"\u2028"
        rep29 = r"\2029"

# Path: pydal/_compat.py
# PY2 = sys.version_info[0] == 2
#     def implements_bool(cls):
#     def implements_iterator(cls):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
#     def to_bytes(obj, charset="utf-8", errors="strict"):
#     def to_native(obj, charset="utf8", errors="strict"):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def to_unicode(obj, charset="utf-8", errors="strict"):
#     class metaclass(meta):


# Path: pydal/helpers/serializers.py
import datetime
import decimal
import json as jsonlib
from .._compat import PY2, integer_types
            from yaml import dump

    _custom_ = {}

    def _json_parse(self, o):
        if hasattr(o, "custom_json") and callable(o.custom_json):
            return o.custom_json()
        if isinstance(o, (datetime.date, datetime.datetime, datetime.time)):
            return o.isoformat()[:19].replace("T", " ")
        elif isinstance(o, long):
            return int(o)
        elif isinstance(o, decimal.Decimal):
            return str(o)
        elif isinstance(o, set):
            return list(o)
        elif hasattr(o, "as_list") and callable(o.as_list):
            return o.as_list()
        elif hasattr(o, "as_dict") and callable(o.as_dict):
            return o.as_dict()
        if self._custom_.get("json") is not None:
            return self._custom_["json"](o)
        raise TypeError(repr(o) + " is not JSON serializable")

    def __getattr__(self, name):
        if self._custom_.get(name) is not None:
            return self._custom_[name]
        raise NotImplementedError("No " + str(name) + " serializer available.")

    def json(self, value):
        value = jsonlib.dumps(value, default=self._json_parse)
        rep28 = r"\u2028"
        rep29 = r"\2029"

        if PY2: