# Path: dockit/schema/signals.py



import os
import sys
            import imp
from django.db.models.loading import AppCache
from django.utils.datastructures import SortedDict
from dockit.schema.signals import document_registered
        from dockit.backends import get_document_router
        from dockit.backends import get_index_router
                # The same model may be imported via different paths (e.g.
                # appname.models and project.appname.models). We use the source
                # filename as a means to detect identity.
                try:
                    fname1 = os.path.abspath(sys.modules[document.__module__].__file__)
                    fname2 = os.path.abspath(sys.modules[document_dict[doc_name].__module__].__file__)
                except KeyError:
                    #TODO handle virtual registration
                    pass
                else:
                    # Since the filename extension could be .py the first time and
                    # .pyc or .pyo the second time, ignore the extension when
                    # comparing.
                    if fname1.endswith('.'+fname2) or fname2.endswith('.'+fname1):
                        continue
            document_dict[doc_name] = document
            self.documents[document._meta.collection] = document
        if self.app_cache_ready():
            self.register_documents_with_backend(documents)
            self.post_app_ready() #TODO find a better solution, like on_app_ready
        else:
            self.pending_documents.extend(documents)
    
    def force_register_documents(self, app_label, *documents):
        document_dict = self.app_documents.setdefault(app_label, SortedDict())
        for document in documents:
            doc_name = document._meta.object_name.lower()
            #TODO detect if any other documents use this as a base document
            document_dict[doc_name] = document
            self.documents[document._meta.collection] = document

# Path: dockit/schema/signals.py



# Path: dockit/schema/loading.py
import os
import sys
            import imp
from django.db.models.loading import AppCache
from django.utils.datastructures import SortedDict
from dockit.schema.signals import document_registered
        from dockit.backends import get_document_router
        from dockit.backends import get_index_router

                # The same model may be imported via different paths (e.g.
                # appname.models and project.appname.models). We use the source
                # filename as a means to detect identity.
                try:
                    fname1 = os.path.abspath(sys.modules[document.__module__].__file__)
                    fname2 = os.path.abspath(sys.modules[document_dict[doc_name].__module__].__file__)
                except KeyError:
                    #TODO handle virtual registration
                    pass
                else:
                    # Since the filename extension could be .py the first time and
                    # .pyc or .pyo the second time, ignore the extension when
                    # comparing.
                    if fname1.endswith('.'+fname2) or fname2.endswith('.'+fname1):
                        continue
            document_dict[doc_name] = document
            self.documents[document._meta.collection] = document
        if self.app_cache_ready():
            self.register_documents_with_backend(documents)
            self.post_app_ready() #TODO find a better solution, like on_app_ready
        else:
            self.pending_documents.extend(documents)
    
    def force_register_documents(self, app_label, *documents):
        document_dict = self.app_documents.setdefault(app_label, SortedDict())
        for document in documents:
            doc_name = document._meta.object_name.lower()
            #TODO detect if any other documents use this as a base document
            document_dict[doc_name] = document
            self.documents[document._meta.collection] = document

        if self.app_cache_ready():