Skip to content
Browse files

Make using optional for both index_queryset and read_queryset

  • Loading branch information...
1 parent 6c4ccb0 commit e3b35fd78b8cb19362927f1cb15ca6ef19c8c4e1 @acdha committed Mar 12, 2012
Showing with 11 additions and 11 deletions.
  1. +1 −1 docs/autocomplete.rst
  2. +1 −1 docs/migration_from_1_to_2.rst
  3. +4 −4 docs/searchindex_api.rst
  4. +1 −1 docs/tutorial.rst
  5. +3 −3 haystack/indexes.py
  6. +1 −1 haystack/query.py
View
2 docs/autocomplete.rst
@@ -42,7 +42,7 @@ Example (continuing from the tutorial)::
def get_model(self):
return Note
- def index_queryset(self):
+ def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return Note.objects.filter(pub_date__lte=datetime.datetime.now())
View
2 docs/migration_from_1_to_2.rst
@@ -155,7 +155,7 @@ A converted Haystack 2.X index should look like::
def get_model(self):
return Note
- def index_queryset(self):
+ def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
View
8 docs/searchindex_api.rst
@@ -34,7 +34,7 @@ For the impatient::
def get_model(self):
return Note
- def index_queryset(self):
+ def index_queryset(self, using=None):
"Used when the entire index for model is updated."
return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
@@ -386,7 +386,7 @@ This method is required & you must override it to return the correct class.
``index_queryset``
------------------
-.. method:: SearchIndex.index_queryset(self)
+.. method:: SearchIndex.index_queryset(self, using=None)
Get the default QuerySet to index when doing a full update.
@@ -395,7 +395,7 @@ Subclasses can override this method to avoid indexing certain objects.
``read_queryset``
-----------------
-.. method:: SearchIndex.read_queryset(self)
+.. method:: SearchIndex.read_queryset(self, using=None)
Get the default QuerySet for read actions.
@@ -609,7 +609,7 @@ For the impatient::
fields = ['user', 'pub_date']
# Note that regular ``SearchIndex`` methods apply.
- def index_queryset(self):
+ def index_queryset(self, using=None):
"Used when the entire index for model is updated."
return Note.objects.filter(pub_date__lte=datetime.datetime.now())
View
2 docs/tutorial.rst
@@ -221,7 +221,7 @@ Haystack to automatically pick it up. The ``NoteIndex`` should look like::
def get_model(self):
return Note
- def index_queryset(self):
+ def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
View
6 haystack/indexes.py
@@ -102,22 +102,22 @@ def get_model(self):
"""
raise NotImplementedError("You must provide a 'model' method for the '%r' index." % self)
- def index_queryset(self, using):
+ def index_queryset(self, using=None):
"""
Get the default QuerySet to index when doing a full update.
Subclasses can override this method to avoid indexing certain objects.
"""
return self.get_model()._default_manager.all()
- def read_queryset(self):
+ def read_queryset(self, using=None):
"""
Get the default QuerySet for read actions.
Subclasses can override this method to work with other managers.
Useful when working with default managers that filter some objects.
"""
- return self.index_queryset()
+ return self.index_queryset(using=using)
def build_queryset(self, start_date=None, end_date=None):
"""
View
2 haystack/query.py
@@ -205,7 +205,7 @@ def post_process_results(self, results):
try:
ui = connections[self.query._using].get_unified_index()
index = ui.get_index(model)
- objects = index.read_queryset()
+ objects = index.read_queryset(using=self.query._using)
loaded_objects[model] = objects.in_bulk(models_pks[model])
except NotHandled:
self.log.warning("Model '%s.%s' not handled by the routers.", self.app_label, self.model_name)

0 comments on commit e3b35fd

Please sign in to comment.
Something went wrong with that request. Please try again.