# Path: dockit/schema/common.py
# class UnSet(object):
# class DotPathTraverser(object):
# class DotPathList(list):
# class DotPathDict(dict):
# class DotPathSet(set):
# class GenericDotPathObject(object):
#     def __nonzero__(self):
#     def __init__(self, dotpath):
#     def resolve_for_schema(self, schema):
#     def resolve_for_instance(self, instance):
#     def resolve_for_raw_data(self, data, schema=None):
#     def _resolve_loop(self):
#     def resolve_next(self):
#     def next_part(self):
#     def current(self):
#     def current_value(self):
#     def current_field(self):
#     def end(self, field=None, value=None):
#     def next(self, field=None, value=None):
#     def set_value(self, value):
#     def traverse_dot_path(self, traverser):
#     def set_value(self, attr, value):
#     def traverse_dot_path(self, traverser):
#     def set_value(self, attr, value):
#     def traverse_dot_path(self, traverser):
#     def set_value(self, attr, value):
#     def __init__(self, value):
#     def traverse_dot_path(self, traverser):


from django.db import models
from django.utils import simplejson
from django.core.serializers.json import DjangoJSONEncoder
from django.core.exceptions import ObjectDoesNotExist
from dockit.schema.common import DotPathTraverser, DotPathNotFound
        from dockit.backends import get_index_router
        from dockit.backends import get_index_router
        from dockit.backends.djangodocument.models import RegisteredIndexDocument
        from dockit.backends.djangodocument.models import RegisteredIndexDocument
        from dockit.schema import Document
class DocumentManager(models.Manager):
    pass

class NotGiven(object):
    def __nonzero__(self):
        return False

class RegisteredIndexManager(models.Manager):
    def __init__(self, *args, **kwargs):
        super(RegisteredIndexManager, self).__init__(*args, **kwargs)
        self.index_models = dict()
    
    def register_index_model(self, data_type, model, instance_types):
        self.index_models[data_type] = {'model':model,
                                        'instance_types':instance_types}
    
    def get_index(self, key):
        return self.index_models[key]
    
    def lookup_index(self, value=NotGiven(), field=NotGiven()):
        if not isinstance(field, NotGiven):
            for data_type, entry in self.index_models.iteritems():
                if field and data_type == getattr(field, 'data_type', None):
                    return entry['model']
        
        if not isinstance(value, NotGiven):
            for entry in self.index_models.itervalues():
                if isinstance(value, entry['instance_types']):
                    return entry['model']
        

# Path: dockit/schema/common.py
# class UnSet(object):
# class DotPathTraverser(object):
# class DotPathList(list):
# class DotPathDict(dict):
# class DotPathSet(set):
# class GenericDotPathObject(object):
#     def __nonzero__(self):
#     def __init__(self, dotpath):
#     def resolve_for_schema(self, schema):
#     def resolve_for_instance(self, instance):
#     def resolve_for_raw_data(self, data, schema=None):
#     def _resolve_loop(self):
#     def resolve_next(self):
#     def next_part(self):
#     def current(self):
#     def current_value(self):
#     def current_field(self):
#     def end(self, field=None, value=None):
#     def next(self, field=None, value=None):
#     def set_value(self, value):
#     def traverse_dot_path(self, traverser):
#     def set_value(self, attr, value):
#     def traverse_dot_path(self, traverser):
#     def set_value(self, attr, value):
#     def traverse_dot_path(self, traverser):
#     def set_value(self, attr, value):
#     def __init__(self, value):
#     def traverse_dot_path(self, traverser):


# Path: dockit/backends/djangodocument/managers.py
from django.db import models
from django.utils import simplejson
from django.core.serializers.json import DjangoJSONEncoder
from django.core.exceptions import ObjectDoesNotExist
from dockit.schema.common import DotPathTraverser, DotPathNotFound
        from dockit.backends import get_index_router
        from dockit.backends import get_index_router
        from dockit.backends.djangodocument.models import RegisteredIndexDocument
        from dockit.backends.djangodocument.models import RegisteredIndexDocument
        from dockit.schema import Document

class DocumentManager(models.Manager):
    pass

class NotGiven(object):
    def __nonzero__(self):
        return False

class RegisteredIndexManager(models.Manager):
    def __init__(self, *args, **kwargs):
        super(RegisteredIndexManager, self).__init__(*args, **kwargs)
        self.index_models = dict()
    
    def register_index_model(self, data_type, model, instance_types):
        self.index_models[data_type] = {'model':model,
                                        'instance_types':instance_types}
    
    def get_index(self, key):
        return self.index_models[key]
    
    def lookup_index(self, value=NotGiven(), field=NotGiven()):
        if not isinstance(field, NotGiven):
            for data_type, entry in self.index_models.iteritems():
                if field and data_type == getattr(field, 'data_type', None):
                    return entry['model']
        
        if not isinstance(value, NotGiven):
            for entry in self.index_models.itervalues():
                if isinstance(value, entry['instance_types']):
                    return entry['model']
        

        if field and getattr(field, 'subfield', None):