# Path: blitzdb/document.py
# class DoesNotExist(BaseException):
# class MultipleDocumentsReturned(BaseException):
# class MetaDocument(type):
#         class DoesNotExist(DoesNotExist):
#         class MultipleDocumentsReturned(MultipleDocumentsReturned):
# class Document(object):
#     class Meta:
#     def __str__(self):
#     def __str__(self):
#     def __new__(meta, name, bases, dct):
#     def __init__(self, attributes=None, lazy=False, backend=None, autoload=True, db_loader = None):
#     def __getitem__(self,key):
#     def lazy(self):
#     def lazy(self,lazy):
#     def lazy_attributes(self):
#     def attributes(self):
#     def attributes(self,value):
#     def get(self,key,default = None):
#     def has_key(self,key):
#     def keys(self):
#     def clear(self):
#     def values(self):
#     def items(self):
#     def properties(self):
#     def properties(self,value):
#     def __contains__(self, key):
#     def __iter__(self):
#     def get_lazy_attribute(self,key):
#     def __getattr__(self, key,load_if_lazy = True):
#     def __setattr__(self, key, value):
#     def __delattr__(self, key):
#     def __delitem__(self, key):
#     def __copy__(self):
#     def __deepcopy__(self, memo):
#     def __hash__(self):
#     def __ne__(self, other):
#     def __nonzero__(self):
#     def __eq__(self, other):
#     def __unicode__(self):
#         def __str__(self):
#     def _represent(self, n=1):
#         def truncate_dict(d, n=n):
#     def initialize(self):
#     def autogenerate_pk(self):
#     def get_pk_name(cls):
#     def pk(self):
#     def embed(self):
#     def eager(self):
#     def pk(self, value):
#     def backend(self):
#     def backend(self,backend):
#     def save(self, backend=None):
#     def delete(self, backend=None):
#     def revert(self, backend=None, implicit=False):
#     def load_if_lazy(self, implicit=False):


import abc
import copy
import inspect
import logging
import six
from blitzdb.document import Document, document_classes

        for encoder in self.standard_encoders+encoders:
            obj = encoder.encode(obj,path = path)

        def encode_as_str(obj):
            if six.PY3:
                return str(obj)
            else:
                if isinstance(obj,unicode):
                    return obj
                elif isinstance(obj,str):
                    return unicode(obj)
                else:
                    return unicode(str(obj),errors='replace')

        if isinstance(obj, dict):
            output_obj = {}
            for key, value in obj.items():
                new_path = path[:]+[key]
                try:
                    output_obj[encode_as_str(key) if convert_keys_to_str else key] = serialize_with_opts(value, embed_level=embed_level,path = new_path)
                except DoNotSerialize:
                    pass
        elif isinstance(obj,six.string_types):
            output_obj = encode_as_str(obj)
        elif isinstance(obj, (list,tuple)):
            try:
                output_obj = [serialize_with_opts(x, embed_level=embed_level,path = path[:]+[i]) for i,x in enumerate(obj)]
            except DoNotSerialize:
                pass

# Path: blitzdb/document.py
# class DoesNotExist(BaseException):
# class MultipleDocumentsReturned(BaseException):
# class MetaDocument(type):
#         class DoesNotExist(DoesNotExist):
#         class MultipleDocumentsReturned(MultipleDocumentsReturned):
# class Document(object):
#     class Meta:
#     def __str__(self):
#     def __str__(self):
#     def __new__(meta, name, bases, dct):
#     def __init__(self, attributes=None, lazy=False, backend=None, autoload=True, db_loader = None):
#     def __getitem__(self,key):
#     def lazy(self):
#     def lazy(self,lazy):
#     def lazy_attributes(self):
#     def attributes(self):
#     def attributes(self,value):
#     def get(self,key,default = None):
#     def has_key(self,key):
#     def keys(self):
#     def clear(self):
#     def values(self):
#     def items(self):
#     def properties(self):
#     def properties(self,value):
#     def __contains__(self, key):
#     def __iter__(self):
#     def get_lazy_attribute(self,key):
#     def __getattr__(self, key,load_if_lazy = True):
#     def __setattr__(self, key, value):
#     def __delattr__(self, key):
#     def __delitem__(self, key):
#     def __copy__(self):
#     def __deepcopy__(self, memo):
#     def __hash__(self):
#     def __ne__(self, other):
#     def __nonzero__(self):
#     def __eq__(self, other):
#     def __unicode__(self):
#         def __str__(self):
#     def _represent(self, n=1):
#         def truncate_dict(d, n=n):
#     def initialize(self):
#     def autogenerate_pk(self):
#     def get_pk_name(cls):
#     def pk(self):
#     def embed(self):
#     def eager(self):
#     def pk(self, value):
#     def backend(self):
#     def backend(self,backend):
#     def save(self, backend=None):
#     def delete(self, backend=None):
#     def revert(self, backend=None, implicit=False):
#     def load_if_lazy(self, implicit=False):


# Path: blitzdb/backends/base.py
import abc
import copy
import inspect
import logging
import six
from blitzdb.document import Document, document_classes


        for encoder in self.standard_encoders+encoders:
            obj = encoder.encode(obj,path = path)

        def encode_as_str(obj):
            if six.PY3:
                return str(obj)
            else:
                if isinstance(obj,unicode):
                    return obj
                elif isinstance(obj,str):
                    return unicode(obj)
                else:
                    return unicode(str(obj),errors='replace')

        if isinstance(obj, dict):
            output_obj = {}
            for key, value in obj.items():
                new_path = path[:]+[key]
                try:
                    output_obj[encode_as_str(key) if convert_keys_to_str else key] = serialize_with_opts(value, embed_level=embed_level,path = new_path)
                except DoNotSerialize:
                    pass
        elif isinstance(obj,six.string_types):
            output_obj = encode_as_str(obj)
        elif isinstance(obj, (list,tuple)):
            try:
                output_obj = [serialize_with_opts(x, embed_level=embed_level,path = path[:]+[i]) for i,x in enumerate(obj)]
            except DoNotSerialize:
                pass

        elif isinstance(obj, Document):