Permalink
Browse files

Make sure an search engine's backend isn't instantiated on every call…

… to the backend but only once. Fixes #580.
  • Loading branch information...
1 parent 47aa888 commit 3a633cb31c533f5492723b1451207a07185f084d @jezdez jezdez committed Jun 20, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 haystack/backends/__init__.py
View
5 haystack/backends/__init__.py
@@ -853,9 +853,12 @@ def __init__(self, using=None):
self.options = settings.HAYSTACK_CONNECTIONS.get(self.using, {})
self.queries = []
self._index = None
+ self._backend = None
def get_backend(self):
- return self.backend(self.using, **self.options)
+ if self._backend is None:
+ self._backend = self.backend(self.using, **self.options)
+ return self._backend
def get_query(self):
return self.query(using=self.using)

0 comments on commit 3a633cb

Please sign in to comment.