# Path: dockit/backends/indexer.py
# class BaseIndexer(object):
#     def __init__(self, document, filter_operation):
#         self.document = document
#         self.filter_operation = filter_operation
#     
#     @property
#     def collection(self):
#         return self.document._meta.collection
#     
#     def on_document_save(self, instance):
#         pass
#     
#     def on_document_delete(self, instance):
#         pass
#     
#     def filter(self):
#         raise NotImplementedError
#     
#     def values(self):
#         raise NotImplementedError


from dockit.backends.indexer import BaseIndexer
from backend import MongoIndexStorage
    from bson.objectid import ObjectId
    from pymongo.objectid import ObjectId


try:
except ImportError:

class MongoIndexer(BaseIndexer):
    def _get_key_value(self):
        dotpath = self.filter_operation.dotpath()
        value = self.filter_operation.value
        if dotpath in ('pk', '_pk', '_id') and value:
            value = ObjectId(value)
        if dotpath in ('pk', '_pk'):
            dotpath = '_id'
        return dotpath, value

class ExactIndexer(MongoIndexer):
    def filter(self):
        dotpath, value = self._get_key_value()
        return {dotpath: value}
    
    def values(self):
        dotpath, value = self._get_key_value()
        return {dotpath: value}

MongoIndexStorage.register_indexer(ExactIndexer, 'exact')


# Path: dockit/backends/indexer.py
# class BaseIndexer(object):
#     def __init__(self, document, filter_operation):
#         self.document = document
#         self.filter_operation = filter_operation
#     
#     @property
#     def collection(self):
#         return self.document._meta.collection
#     
#     def on_document_save(self, instance):
#         pass
#     
#     def on_document_delete(self, instance):
#         pass
#     
#     def filter(self):
#         raise NotImplementedError
#     
#     def values(self):
#         raise NotImplementedError


# Path: dockit/backends/mongo/indexers.py
from dockit.backends.indexer import BaseIndexer
from backend import MongoIndexStorage
    from bson.objectid import ObjectId
    from pymongo.objectid import ObjectId



try:
except ImportError:

class MongoIndexer(BaseIndexer):
    def _get_key_value(self):
        dotpath = self.filter_operation.dotpath()
        value = self.filter_operation.value
        if dotpath in ('pk', '_pk', '_id') and value:
            value = ObjectId(value)
        if dotpath in ('pk', '_pk'):
            dotpath = '_id'
        return dotpath, value

class ExactIndexer(MongoIndexer):
    def filter(self):
        dotpath, value = self._get_key_value()
        return {dotpath: value}
    
    def values(self):
        dotpath, value = self._get_key_value()
        return {dotpath: value}

MongoIndexStorage.register_indexer(ExactIndexer, 'exact')


class OperationIndexer(MongoIndexer):