# 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
            index_doc.data = encoded_data
            index_doc.save()
        for param in query_index.indexes:
            dotpath = param.dotpath()
            traverser = DotPathTraverser(dotpath)
            try:
                traverser.resolve_for_raw_data(data, schema=schema)
            except DotPathNotFound:
                value = None
                field = None
            except ObjectDoesNotExist:
                value = None
                field = None
            else:
                value = traverser.current_value
                field = traverser.current_field
            index_model = self.lookup_index(value=value, field=field)
            #now create a BaseIndex entry associated to a registered index document
            #if param.key == '@natural_key_hash':
            #    assert value
            #    assert False, str(value) +':'+ str(index_model)
            
            index_model.objects.db_index(index_doc, param.key, value)

class BaseIndexManager(models.Manager):
    def filter_kwargs_for_operation(self, operation):
        if operation.key in ('pk', '_pk'):
            return {'pk__%s' % operation.operation: operation.value}
        prefix = self.model._meta.get_field('document').related.var_name
        filter_kwargs = dict()

# 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

            index_doc.data = encoded_data
            index_doc.save()
        for param in query_index.indexes:
            dotpath = param.dotpath()
            traverser = DotPathTraverser(dotpath)
            try:
                traverser.resolve_for_raw_data(data, schema=schema)
            except DotPathNotFound:
                value = None
                field = None
            except ObjectDoesNotExist:
                value = None
                field = None
            else:
                value = traverser.current_value
                field = traverser.current_field
            index_model = self.lookup_index(value=value, field=field)
            #now create a BaseIndex entry associated to a registered index document
            #if param.key == '@natural_key_hash':
            #    assert value
            #    assert False, str(value) +':'+ str(index_model)
            
            index_model.objects.db_index(index_doc, param.key, value)

class BaseIndexManager(models.Manager):
    def filter_kwargs_for_operation(self, operation):
        if operation.key in ('pk', '_pk'):
            return {'pk__%s' % operation.operation: operation.value}
        prefix = self.model._meta.get_field('document').related.var_name
        filter_kwargs = dict()

        filter_kwargs['%s__param_name' % prefix] = operation.key