mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-24 06:43:46 +00:00
Search: Various tweaks to backend importer
This commit is contained in:
parent
dacdacfc0d
commit
ae6bd25d17
1 changed files with 9 additions and 2 deletions
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
from importlib import import_module
|
||||
from django.utils import six
|
||||
import sys
|
||||
from django.conf import settings
|
||||
from base import InvalidSearchBackendError
|
||||
|
||||
|
||||
# Pinched from django 1.7 source code.
|
||||
|
|
@ -45,8 +47,13 @@ def get_search_backend(backend='default', **kwargs):
|
|||
# Try to get the WAGTAILSEARCH_BACKENDS entry for the given backend name first
|
||||
conf = WAGTAILSEARCH_BACKENDS[backend]
|
||||
except KeyError:
|
||||
raise InvalidSearchBackendError("Could not find backend '%s': %s" % (
|
||||
backend, e))
|
||||
try:
|
||||
# Trying to import the given backend, in case it's a dotted path
|
||||
import_string(backend)
|
||||
except ImportError as e:
|
||||
raise InvalidSearchBackendError("Could not find backend '%s': %s" % (
|
||||
backend, e))
|
||||
params = kwargs
|
||||
else:
|
||||
# Backend is a conf entry
|
||||
params = conf.copy()
|
||||
|
|
|
|||
Loading…
Reference in a new issue