# 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
                    # .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():
            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 register_documents_with_backend(self, documents):
        router = get_document_router()
        
        for document in documents:
            router.register_document(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

                    # .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():
            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 register_documents_with_backend(self, documents):
        router = get_document_router()
        
        for document in documents:
            router.register_document(document)

            document_registered.send_robust(sender=document._meta.collection, document=document)