django-haystack / django-haystack/django-haystack
Allow HAYSTACK_SIGNAL_PROCESSOR Class to Import Models
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 1.3k
- Avg merge
- 3h 18m
- Merged PRs (30d)
- 3
Description
Currently, if you use the HAYSTACK_SIGNAL_PROCESSOR function to set to a class which imports a model, then you can get ciruclar imports. This was also reported here:
http://stackoverflow.com/questions/17049426/importerror-when-using-haystack-2-0-0-with-django-1-5-and-gunicorn-wsgi
It would be nice if our signal processors could import our models.
I think the issue is in __init__.py here:
# Setup the signal processor.
signal_processor_path = getattr(settings, 'HAYSTACK_SIGNAL_PROCESSOR',
'haystack.signals.BaseSignalProcessor')
signal_processor_class = loading.import_class(signal_processor_path)
signal_processor = signal_processor_class(connections, connection_router)
We should not be importing or instantiating this class within __init__.py, otherwise it can easily cause circular imports. Instead, we should try to lazy load it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in init.py at the signal processor setup and read how loading.import_class and instantiation are performed. Reproduce the configuration with a HAYSTACK_SIGNAL_PROCESSOR class that imports a model, then trace the circular import. Done means signal processors can import models without causing circular imports during initialization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100