def update(app_label, object_name, manager_name, parent_pk, delete):
    model = models.get_model(app_label, object_name)
    try:
        manager = getattr(model, manager_name)
    except AttributeError:
        # AttributeError: type object 'conceptdb' has no attribute 'concepts1'
        # JC July 5, 2012
        # Deferred tasks not recognizing django search indexes so run autodiscover (which is in settings.py but not always there)
        from dbindexer import autodiscover
        autodiscover()
#        logging.warning("Likely couldn't find search index so ran autodiscover")
#        logging.info(str(model)) # <class 'concept.models.conceptdb'>
        logging.warning("Manually importing search index algorithms (concepts1 index thing)") 
#        app="dbindexes"
#        module_name="dbindexes"
#        import_module('%s.%s' % (app, module_name))
        app="concept"
        import_module("concept.search_indexes")
        app="tool"                          
        import_module("tool.search_indexes") # Was failing on jc-alg2 import on newly restarted tasks.
        
        manager = getattr(model, manager_name) # re-run
    manager.update_relation_index(parent_pk, delete)
Example #2
0
# Search for "dbindexes.py" in all installed apps
from dbindexer import autodiscover
autodiscover()
# dbindexes.py:
import dbindexer
dbindexer.autodiscover()
Example #4
0
from dbindexer import autodiscover
autodiscover()
Example #5
0
from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
import dbindexer
dbindexer.autodiscover() #This needs to happen before anything else, hence strange import ordering

urlpatterns = patterns('harvester.views',
    url(r'^$', 'home', name='home'),
    url(r'^settings/', 'settings', name='settings'),
    # Examples:
    # url(r'^$', 'harvester.views.home', name='home'),
    # url(r'^harvester/', include('harvester.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
)