toastdriven/django-haystack — pull request #587 by mattdeboard (2012-06-15 18:37:54+00:00)
Title: Refactor SolrSearchBackend.search so that kwarg-generation operations are in a discrete method.

This makes it much simpler to subclass ``SolrSearchBackend`` to add support for new parameters. Currently, you have to -- as far as I know -- copy and paste the entire ``search`` method and insert your code where needed. By factoring out the creation of the dictionary to a discrete method you can simply override & extend the ``_build_search_kwargs`` method:

```python
class MySolrSearchBackend(SolrSearchBackend):
def _build_search_kwargs(new_param="somevalue", **kwargs):
kwargs = super(MySolrSearchBackend, self)._build_search_kwargs(**kwargs)
kwargs['new_param'] = new_param
return kwargs
```

All tests pass.