Anonymous committed 3affe04

adapted to django-autoload

Comments (0)

Files changed (2)


 from search.core import default_splitter, site_language, SearchManager, \
+from autoload import autodiscover as auto_discover
 def autodiscover():
-    """
-    Automatically add managers from search_indexes modules.
-    """
-    import imp
-    from django.conf import settings
-    from django.utils.importlib import import_module
-    for app in settings.INSTALLED_APPS:
-        # For each app, we need to look for an inside that app's
-        # package. We can't use os.path here -- recall that modules may be
-        # imported different ways (think zip files) -- so we need to get
-        # the app's __path__ and look for on that path.
-        # Step 1: find out the app's __path__ Import errors here will (and
-        # should) bubble up, but a missing __path__ (which is legal, but weird)
-        # fails silently -- apps that do weird things with __path__ might
-        # need to roll their own index registration.
-        try:
-            app_path = import_module(app).__path__
-        except AttributeError:
-            continue
-        # Step 2: use imp.find_module to find the app's For some
-        # reason imp.find_module raises ImportError if the app can't be found
-        # but doesn't actually try to import the module. So skip this app if
-        # its doesn't exist
-        try:
-            imp.find_module('search_indexes', app_path)
-        except ImportError:
-            continue
-        # Step 3: import the app's search_index file. If this has errors we want them
-        # to bubble up.
-        import_module("%s.search_indexes" % app)
+    auto_discover('search_indexes')
 def register(model, fields_to_index, search_index='search_index',
     indexer=None, splitter=default_splitter, relation_index=True, integrate='*',
             Indexed(extra_data=extra_data, one=u'one%d' % i, two='two%d' % i).save()
         for i in range(3):
-            Indexed(extra_data=extra_data, one=(None, u'ÜÄÖ-+!#><|', 'blub')[i],
+            Indexed(extra_data=extra_data, one=(None, u'ÜÄÖ-+!#><|', 'blub')[i],
                     check=bool(i%2), value=u'value%d test-word' % i).save()
         for i in range(3):
             check=False)), 1)
-            check=True, one=u'ÜÄÖ-+!#><|')), 1)
+            check=True, one=u'ÜÄÖ-+!#><|')), 1)
             check__exact=False, one='blub')), 1)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.