# 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
# class Serializers(object):
#     def _json_parse(self, o):
#     def __getattr__(self, name):
#     def json(self, value):
#     def yaml(self, value):


import copy
import marshal
import struct
import threading
import time
import traceback
            import types
from .._compat import (
    PY2,
    exists,
    copyreg,
    implements_bool,
    iterkeys,
    itervalues,
    iteritems,
    to_bytes,
    long,
)
from .._globals import THREAD_LOCAL
from .serializers import serializers
        self.data += data

    def close_connection(self):
        if self.db is not None:
            self.db.executesql(
                "DELETE FROM web2py_filesystem WHERE path='%s'" % self.filename
            )
            query = "INSERT INTO web2py_filesystem(path,content) VALUES (%s, %s)"
            args = (to_bytes(self.filename), self.data)
            self.db.executesql(query, args)
            self.db.commit()
            self.db = None

    def close(self):
        self.close_connection()

    @staticmethod
    def is_operational_error(db, error):
        if not hasattr(db._adapter.driver, "OperationalError"):
            return None
        return isinstance(error, db._adapter.driver.OperationalError)

    @staticmethod
    def is_programming_error(db, error):
        if not hasattr(db._adapter.driver, "ProgrammingError"):
            return None
        return isinstance(error, db._adapter.driver.ProgrammingError)

    @staticmethod
    def exists(db, filename):

# 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
# class Serializers(object):
#     def _json_parse(self, o):
#     def __getattr__(self, name):
#     def json(self, value):
#     def yaml(self, value):


# Path: pydal/helpers/classes.py
import copy
import marshal
import struct
import threading
import time
import traceback
            import types
from .._compat import (
    PY2,
    exists,
    copyreg,
    implements_bool,
    iterkeys,
    itervalues,
    iteritems,
    to_bytes,
    long,
)
from .._globals import THREAD_LOCAL
from .serializers import serializers

        self.data += data

    def close_connection(self):
        if self.db is not None:
            self.db.executesql(
                "DELETE FROM web2py_filesystem WHERE path='%s'" % self.filename
            )
            query = "INSERT INTO web2py_filesystem(path,content) VALUES (%s, %s)"
            args = (to_bytes(self.filename), self.data)
            self.db.executesql(query, args)
            self.db.commit()
            self.db = None

    def close(self):
        self.close_connection()

    @staticmethod
    def is_operational_error(db, error):
        if not hasattr(db._adapter.driver, "OperationalError"):
            return None
        return isinstance(error, db._adapter.driver.OperationalError)

    @staticmethod
    def is_programming_error(db, error):
        if not hasattr(db._adapter.driver, "ProgrammingError"):
            return None
        return isinstance(error, db._adapter.driver.ProgrammingError)

    @staticmethod
    def exists(db, filename):

        if exists(filename):