[Python-modules-commits] [celery-haystack] 06/10: Import celery-haystack_0.10.orig.tar.gz
Michael Fladischer
fladi at moszumanska.debian.org
Sat Jan 2 13:02:07 UTC 2016
This is an automated email from the git hooks/post-receive script.
fladi pushed a commit to branch master
in repository celery-haystack.
commit 8a058bc8b48df136b3583fba8df9d246ab395c2b
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date: Sat Jan 2 13:43:22 2016 +0100
Import celery-haystack_0.10.orig.tar.gz
---
.gitignore | 11 --
.travis.yml | 48 ------
PKG-INFO | 117 +++++++++++++
README.rst | 50 +-----
celery_haystack.egg-info/PKG-INFO | 117 +++++++++++++
celery_haystack.egg-info/SOURCES.txt | 25 +++
celery_haystack.egg-info/dependency_links.txt | 1 +
celery_haystack.egg-info/not-zip-safe | 1 +
celery_haystack.egg-info/requires.txt | 1 +
celery_haystack.egg-info/top_level.txt | 1 +
celery_haystack/__init__.py | 2 +-
celery_haystack/conf.py | 4 +-
celery_haystack/indexes.py | 50 +-----
celery_haystack/tasks.py | 34 +---
celery_haystack/test_settings.py | 23 +--
celery_haystack/tests/search_indexes.py | 14 +-
celery_haystack/tests/tests.py | 4 +-
celery_haystack/utils.py | 30 +++-
docs/Makefile | 130 ---------------
docs/changelog.rst | 167 -------------------
docs/conf.py | 228 --------------------------
docs/index.rst | 8 -
docs/make.bat | 170 -------------------
requirements/v1.txt | 7 -
requirements/v2.txt | 7 -
setup.cfg | 58 ++++---
26 files changed, 344 insertions(+), 964 deletions(-)
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index dcbc81b..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-.DS_Store
-*.pyc
-celery_haystack/tests/whoosh_index
-*.egg
-*.egg-info
-.coverage
-docs/_build
-build/
-dist/
-.eggs/
-MANIFEST
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 28f6a9d..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-language: python
-python:
- - "2.6"
- - "2.7"
- - "3.3"
- - "3.4"
-before_install:
- - export DJANGO_SETTINGS_MODULE=celery_haystack.test_settings
-install:
- - pip install -e .
- - pip install -r requirements/$HAYSTACK.txt $DJANGO
-before_script:
- - flake8 celery_haystack --ignore=E501
-script:
- - coverage run --branch --source=celery_haystack `which django-admin.py` test celery_haystack
- - coverage report --omit=celery_haystack/test*
-env:
- - DJANGO="Django==1.4.20" HAYSTACK=v1
- - DJANGO="Django==1.4.20" HAYSTACK=v2
- - DJANGO="Django==1.7.8" HAYSTACK=v1
- - DJANGO="Django==1.7.8" HAYSTACK=v2
- - DJANGO="Django==1.8.2" HAYSTACK=v2
-matrix:
- exclude:
- - env: DJANGO="Django==1.4.20" HAYSTACK=v1
- python: "3.3"
- - env: DJANGO="Django==1.4.20" HAYSTACK=v2
- python: "3.3"
- - env: DJANGO="Django==1.4.20" HAYSTACK=v1
- python: "3.4"
- - env: DJANGO="Django==1.4.20" HAYSTACK=v2
- python: "3.4"
- - env: DJANGO="Django==1.7.8" HAYSTACK=v1
- python: "2.6"
- - env: DJANGO="Django==1.7.8" HAYSTACK=v2
- python: "2.6"
- - env: DJANGO="Django==1.8.2" HAYSTACK=v1
- python: "2.6"
- - env: DJANGO="Django==1.8.2" HAYSTACK=v2
- python: "2.6"
- - env: DJANGO="Django==1.7.8" HAYSTACK=v1
- python: "3.3"
- - env: DJANGO="Django==1.7.8" HAYSTACK=v1
- python: "3.4"
- - env: DJANGO="Django==1.8.2" HAYSTACK=v1
- python: "3.3"
- - env: DJANGO="Django==1.8.2" HAYSTACK=v1
- python: "3.4"
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..34c9ab6
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,117 @@
+Metadata-Version: 1.1
+Name: celery-haystack
+Version: 0.10
+Summary: An app for integrating Celery with Haystack.
+Home-page: http://celery-haystack.rtfd.org/
+Author: Jannis Leidel
+Author-email: jannis at leidel.info
+License: UNKNOWN
+Description: ===============
+ celery-haystack
+ ===============
+
+ .. image:: https://secure.travis-ci.org/django-haystack/celery-haystack.png?branch=develop
+ :alt: Build Status
+ :target: http://travis-ci.org/django-haystack/celery-haystack
+
+ This Django app allows you to utilize Celery for automatically updating and
+ deleting objects in a Haystack_ search index.
+
+ Requirements
+ ------------
+
+ * Django 1.8+
+ * Haystack_ `2.X`_
+ * Celery_ 3.X
+
+ You also need to install your choice of one of the supported search engines
+ for Haystack and one of the supported backends for Celery.
+
+
+ .. _Haystack: http://haystacksearch.org
+ .. _Celery: http://www.celeryproject.org
+
+
+ Installation
+ ------------
+
+ Use your favorite Python package manager to install the app from PyPI, e.g.::
+
+ pip install celery-haystack
+
+
+ For Django < 1.9 you need to install and configure `django-transaction-hooks`_ -- an app that
+ brings transaction commit hooks to Django.
+
+ .. _django-transaction-hooks: https://github.com/carljm/django-transaction-hooks
+
+
+ Usage
+ -----
+
+ 1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting
+
+ .. code:: python
+
+ INSTALLED_APPS = [
+ # ..
+ 'celery_haystack',
+ ]
+
+ 2. Enable the celery-haystack signal processor in the settings
+
+ .. code:: python
+
+ HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
+
+ 3. Alter all of your ``SearchIndex`` subclasses to inherit from
+ ``celery_haystack.indexes.CelerySearchIndex`` and
+ ``haystack.indexes.Indexable``
+
+ .. code:: python
+
+ from haystack import indexes
+ from celery_haystack.indexes import CelerySearchIndex
+ from myapp.models import Note
+
+ class NoteIndex(CelerySearchIndex, indexes.Indexable):
+ text = indexes.CharField(document=True, model_attr='content')
+
+ def get_model(self):
+ return Note
+
+ 4. Ensure your Celery instance is running.
+
+ Thanks
+ ------
+
+ This app is a blatant rip-off of Daniel Lindsley's queued_search_
+ app but uses Ask Solem Hoel's Celery_ instead of the equally awesome
+ queues_ library by Matt Croyden.
+
+ .. _queued_search: https://github.com/toastdriven/queued_search/
+ .. _Celery: http://celeryproject.org/
+ .. _queues: http://code.google.com/p/queues/
+
+ Issues
+ ------
+
+ Please use the `Github issue tracker`_ for any bug reports or feature
+ requests.
+
+ .. _`Github issue tracker`: https://github.com/django-haystack/celery-haystack/issues
+
+
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Environment :: Web Environment
+Classifier: Framework :: Django
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Topic :: Utilities
diff --git a/README.rst b/README.rst
index cd62304..656fba1 100644
--- a/README.rst
+++ b/README.rst
@@ -12,8 +12,8 @@ deleting objects in a Haystack_ search index.
Requirements
------------
-* Django 1.4+
-* Haystack_ `1.2.X`_ *or* `2.X`_
+* Django 1.8+
+* Haystack_ `2.X`_
* Celery_ 3.X
You also need to install your choice of one of the supported search engines
@@ -21,8 +21,8 @@ for Haystack and one of the supported backends for Celery.
.. _Haystack: http://haystacksearch.org
-.. _`1.2.X`: http://pypi.python.org/pypi/django-haystack/1.2.5
-.. _`2.X`: https://github.com/toastdriven/django-haystack/tree/master
+.. _Celery: http://www.celeryproject.org
+
Installation
------------
@@ -31,52 +31,16 @@ Use your favorite Python package manager to install the app from PyPI, e.g.::
pip install celery-haystack
-By default a few dependencies will automatically be installed:
-- django-appconf_ -- An app to gracefully handle application settings.
+For Django < 1.9 you need to install and configure `django-transaction-hooks`_ -- an app that
+brings transaction commit hooks to Django.
-- `django-celery-transactions`_ -- An app that "holds on to Celery tasks
- until the current database transaction is committed, avoiding potential
- race conditions as described in `Celery's user guide`_."
+.. _django-transaction-hooks: https://github.com/carljm/django-transaction-hooks
-.. _django-appconf: http://pypi.python.org/pypi/django-appconf
-.. _`django-celery-transactions`: https://github.com/chrisdoble/django-celery-transactions
-.. _`Celery's user guide`: http://celery.readthedocs.org/en/latest/userguide/tasks.html#database-transactions
Usage
-----
-Haystack 1.X
-~~~~~~~~~~~~
-
-1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting
-
- .. code:: python
-
- INSTALLED_APPS = [
- # ..
- 'celery_haystack',
- ]
-
-2. Alter all of your ``SearchIndex`` subclasses to inherit from
- ``celery_haystack.indexes.CelerySearchIndex``
-
- .. code:: python
-
- from haystack import site, indexes
- from celery_haystack.indexes import CelerySearchIndex
- from myapp.models import Note
-
- class NoteIndex(CelerySearchIndex):
- text = indexes.CharField(document=True, model_attr='content')
-
- site.register(Note, NoteIndex)
-
-3. Ensure your Celery instance is running.
-
-Haystack 2.X
-~~~~~~~~~~~~
-
1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting
.. code:: python
diff --git a/celery_haystack.egg-info/PKG-INFO b/celery_haystack.egg-info/PKG-INFO
new file mode 100644
index 0000000..34c9ab6
--- /dev/null
+++ b/celery_haystack.egg-info/PKG-INFO
@@ -0,0 +1,117 @@
+Metadata-Version: 1.1
+Name: celery-haystack
+Version: 0.10
+Summary: An app for integrating Celery with Haystack.
+Home-page: http://celery-haystack.rtfd.org/
+Author: Jannis Leidel
+Author-email: jannis at leidel.info
+License: UNKNOWN
+Description: ===============
+ celery-haystack
+ ===============
+
+ .. image:: https://secure.travis-ci.org/django-haystack/celery-haystack.png?branch=develop
+ :alt: Build Status
+ :target: http://travis-ci.org/django-haystack/celery-haystack
+
+ This Django app allows you to utilize Celery for automatically updating and
+ deleting objects in a Haystack_ search index.
+
+ Requirements
+ ------------
+
+ * Django 1.8+
+ * Haystack_ `2.X`_
+ * Celery_ 3.X
+
+ You also need to install your choice of one of the supported search engines
+ for Haystack and one of the supported backends for Celery.
+
+
+ .. _Haystack: http://haystacksearch.org
+ .. _Celery: http://www.celeryproject.org
+
+
+ Installation
+ ------------
+
+ Use your favorite Python package manager to install the app from PyPI, e.g.::
+
+ pip install celery-haystack
+
+
+ For Django < 1.9 you need to install and configure `django-transaction-hooks`_ -- an app that
+ brings transaction commit hooks to Django.
+
+ .. _django-transaction-hooks: https://github.com/carljm/django-transaction-hooks
+
+
+ Usage
+ -----
+
+ 1. Add ``'celery_haystack'`` to the ``INSTALLED_APPS`` setting
+
+ .. code:: python
+
+ INSTALLED_APPS = [
+ # ..
+ 'celery_haystack',
+ ]
+
+ 2. Enable the celery-haystack signal processor in the settings
+
+ .. code:: python
+
+ HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
+
+ 3. Alter all of your ``SearchIndex`` subclasses to inherit from
+ ``celery_haystack.indexes.CelerySearchIndex`` and
+ ``haystack.indexes.Indexable``
+
+ .. code:: python
+
+ from haystack import indexes
+ from celery_haystack.indexes import CelerySearchIndex
+ from myapp.models import Note
+
+ class NoteIndex(CelerySearchIndex, indexes.Indexable):
+ text = indexes.CharField(document=True, model_attr='content')
+
+ def get_model(self):
+ return Note
+
+ 4. Ensure your Celery instance is running.
+
+ Thanks
+ ------
+
+ This app is a blatant rip-off of Daniel Lindsley's queued_search_
+ app but uses Ask Solem Hoel's Celery_ instead of the equally awesome
+ queues_ library by Matt Croyden.
+
+ .. _queued_search: https://github.com/toastdriven/queued_search/
+ .. _Celery: http://celeryproject.org/
+ .. _queues: http://code.google.com/p/queues/
+
+ Issues
+ ------
+
+ Please use the `Github issue tracker`_ for any bug reports or feature
+ requests.
+
+ .. _`Github issue tracker`: https://github.com/django-haystack/celery-haystack/issues
+
+
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Environment :: Web Environment
+Classifier: Framework :: Django
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Topic :: Utilities
diff --git a/celery_haystack.egg-info/SOURCES.txt b/celery_haystack.egg-info/SOURCES.txt
new file mode 100644
index 0000000..c941945
--- /dev/null
+++ b/celery_haystack.egg-info/SOURCES.txt
@@ -0,0 +1,25 @@
+AUTHORS
+LICENSE
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+celery_haystack/__init__.py
+celery_haystack/conf.py
+celery_haystack/indexes.py
+celery_haystack/models.py
+celery_haystack/signals.py
+celery_haystack/tasks.py
+celery_haystack/test_settings.py
+celery_haystack/utils.py
+celery_haystack.egg-info/PKG-INFO
+celery_haystack.egg-info/SOURCES.txt
+celery_haystack.egg-info/dependency_links.txt
+celery_haystack.egg-info/not-zip-safe
+celery_haystack.egg-info/requires.txt
+celery_haystack.egg-info/top_level.txt
+celery_haystack/tests/__init__.py
+celery_haystack/tests/models.py
+celery_haystack/tests/search_indexes.py
+celery_haystack/tests/search_sites.py
+celery_haystack/tests/tests.py
\ No newline at end of file
diff --git a/celery_haystack.egg-info/dependency_links.txt b/celery_haystack.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/celery_haystack.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/celery_haystack.egg-info/not-zip-safe b/celery_haystack.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/celery_haystack.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/celery_haystack.egg-info/requires.txt b/celery_haystack.egg-info/requires.txt
new file mode 100644
index 0000000..fe25289
--- /dev/null
+++ b/celery_haystack.egg-info/requires.txt
@@ -0,0 +1 @@
+django-appconf>=0.4.1
diff --git a/celery_haystack.egg-info/top_level.txt b/celery_haystack.egg-info/top_level.txt
new file mode 100644
index 0000000..6a7b6f3
--- /dev/null
+++ b/celery_haystack.egg-info/top_level.txt
@@ -0,0 +1 @@
+celery_haystack
diff --git a/celery_haystack/__init__.py b/celery_haystack/__init__.py
index 76de8d7..2678360 100644
--- a/celery_haystack/__init__.py
+++ b/celery_haystack/__init__.py
@@ -1,4 +1,4 @@
-__version__ = '0.9'
+__version__ = '0.10'
def version_hook(config):
diff --git a/celery_haystack/conf.py b/celery_haystack/conf.py
index 4298ae9..5af93a4 100644
--- a/celery_haystack/conf.py
+++ b/celery_haystack/conf.py
@@ -1,6 +1,6 @@
from django.conf import settings # noqa
from django.core.exceptions import ImproperlyConfigured
-from haystack import constants, __version__ as haystack_version
+from haystack import constants
from haystack.management.commands import update_index as cmd
from appconf import AppConf
@@ -56,7 +56,7 @@ class CeleryHaystack(AppConf):
signal_processor = getattr(settings, 'HAYSTACK_SIGNAL_PROCESSOR', None)
-if haystack_version[0] >= 2 and signal_processor is None:
+if signal_processor is None:
raise ImproperlyConfigured("When using celery-haystack with Haystack 2.X "
"the HAYSTACK_SIGNAL_PROCESSOR setting must be "
"set. Use 'celery_haystack.signals."
diff --git a/celery_haystack/indexes.py b/celery_haystack/indexes.py
index 4899c06..07dbf90 100644
--- a/celery_haystack/indexes.py
+++ b/celery_haystack/indexes.py
@@ -1,53 +1,5 @@
-from django.db.models import signals
-
from haystack import indexes
-from .utils import enqueue_task
-
class CelerySearchIndex(indexes.SearchIndex):
- """
- A ``SearchIndex`` subclass that enqueues updates/deletes for later
- processing using Celery.
- """
- # We override the built-in _setup_* methods to connect the enqueuing
- # operation.
- def _setup_save(self, model):
- signals.post_save.connect(self.enqueue_save,
- sender=model,
- dispatch_uid=CelerySearchIndex)
-
- def _setup_delete(self, model):
- signals.post_delete.connect(self.enqueue_delete,
- sender=model,
- dispatch_uid=CelerySearchIndex)
-
- def _teardown_save(self, model):
- signals.post_save.disconnect(self.enqueue_save,
- sender=model,
- dispatch_uid=CelerySearchIndex)
-
- def _teardown_delete(self, model):
- signals.post_delete.disconnect(self.enqueue_delete,
- sender=model,
- dispatch_uid=CelerySearchIndex)
-
- def enqueue_save(self, instance, **kwargs):
- if not getattr(instance, 'skip_indexing', False):
- return self.enqueue('update', instance)
-
- def enqueue_delete(self, instance, **kwargs):
- if not getattr(instance, 'skip_indexing', False):
- return self.enqueue('delete', instance)
-
- def enqueue(self, action, instance):
- """
- Shoves a message about how to update the index into the queue.
-
- This is a standardized string, resembling something like::
-
- ``notes.note.23``
- # ...or...
- ``weblog.entry.8``
- """
- return enqueue_task(action, instance)
+ pass
diff --git a/celery_haystack/tasks.py b/celery_haystack/tasks.py
index 34fac4e..09e54de 100644
--- a/celery_haystack/tasks.py
+++ b/celery_haystack/tasks.py
@@ -1,26 +1,14 @@
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
-from django.db.models.loading import get_model
+from django.apps import apps
+get_model = apps.get_model
from .conf import settings
-try:
- from haystack import connections, connection_router
- from haystack.exceptions import NotHandled as IndexNotFoundException
- legacy = False
-except ImportError:
- try:
- from haystack import site
- from haystack.exceptions import NotRegistered as IndexNotFoundException # noqa
- legacy = True
- except ImportError as e:
- raise ImproperlyConfigured("Haystack couldn't be imported: %s" % e)
-
-if settings.CELERY_HAYSTACK_TRANSACTION_SAFE and not getattr(settings, 'CELERY_ALWAYS_EAGER', False):
- from djcelery_transactions import PostTransactionTask as Task
-else:
- from celery.task import Task # noqa
+from haystack import connections, connection_router
+from haystack.exceptions import NotHandled as IndexNotFoundException
+from celery.task import Task # noqa
from celery.utils.log import get_task_logger
logger = get_task_logger(__name__)
@@ -83,14 +71,10 @@ class CeleryHaystackSignalHandler(Task):
Fetch the model's registered ``SearchIndex`` in a standarized way.
"""
try:
- if legacy:
- index_holder = site
- yield index_holder.get_index(model_class), self.using
- else:
- using_backends = connection_router.for_write(**{'models': [model_class]})
- for using in using_backends:
- index_holder = connections[using].get_unified_index()
- yield index_holder.get_index(model_class), using
+ using_backends = connection_router.for_write(**{'models': [model_class]})
+ for using in using_backends:
+ index_holder = connections[using].get_unified_index()
+ yield index_holder.get_index(model_class), using
except IndexNotFoundException:
raise ImproperlyConfigured("Couldn't find a SearchIndex for %s." %
model_class)
diff --git a/celery_haystack/test_settings.py b/celery_haystack/test_settings.py
index 8dbfb62..def8536 100644
--- a/celery_haystack/test_settings.py
+++ b/celery_haystack/test_settings.py
@@ -1,7 +1,5 @@
import os
-import django
-
from celery import Celery
app = Celery('celery_haystack')
@@ -34,19 +32,10 @@ CELERY_IGNORE_RESULT = True
CELERYD_LOG_LEVEL = "DEBUG"
CELERY_DEFAULT_QUEUE = "celery-haystack"
-if django.VERSION < (1, 6):
- TEST_RUNNER = 'discover_runner.DiscoverRunner'
-
-if os.environ.get('HAYSTACK') == 'v1':
- HAYSTACK_SITECONF = 'celery_haystack.tests.search_sites'
- HAYSTACK_SEARCH_ENGINE = 'whoosh'
- HAYSTACK_WHOOSH_PATH = os.path.join(TEST_ROOT, 'whoosh_index')
-
-elif os.environ.get('HAYSTACK') == 'v2':
- HAYSTACK_CONNECTIONS = {
- 'default': {
- 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
- 'PATH': os.path.join(TEST_ROOT, 'whoosh_index'),
- }
+HAYSTACK_CONNECTIONS = {
+ 'default': {
+ 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
+ 'PATH': os.path.join(TEST_ROOT, 'whoosh_index'),
}
- HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
+}
+HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
diff --git a/celery_haystack/tests/search_indexes.py b/celery_haystack/tests/search_indexes.py
index 7aa4fbd..242958f 100644
--- a/celery_haystack/tests/search_indexes.py
+++ b/celery_haystack/tests/search_indexes.py
@@ -1,17 +1,8 @@
-from haystack import indexes, __version__ as haystack_version
+from haystack import indexes
from .models import Note
from ..indexes import CelerySearchIndex
-if haystack_version[:2] < (2, 0):
- from haystack import site
-
- class Indexable(object):
- pass
- indexes.Indexable = Indexable
-else:
- site = None # noqa
-
# Simplest possible subclass that could work.
class NoteIndex(CelerySearchIndex, indexes.Indexable):
@@ -19,6 +10,3 @@ class NoteIndex(CelerySearchIndex, indexes.Indexable):
def get_model(self):
return Note
-
-if site:
- site.register(Note, NoteIndex)
diff --git a/celery_haystack/tests/tests.py b/celery_haystack/tests/tests.py
index 43f2384..d6fbe75 100644
--- a/celery_haystack/tests/tests.py
+++ b/celery_haystack/tests/tests.py
@@ -1,12 +1,12 @@
from django.core.management import call_command
-from django.test import TestCase
+from django.test import TransactionTestCase
from haystack.query import SearchQuerySet
from .models import Note
-class QueuedSearchIndexTestCase(TestCase):
+class QueuedSearchIndexTestCase(TransactionTestCase):
def assertSearchResultLength(self, count):
self.assertEqual(count, len(SearchQuerySet()))
diff --git a/celery_haystack/utils.py b/celery_haystack/utils.py
index e351b2e..9cb4938 100644
--- a/celery_haystack/utils.py
+++ b/celery_haystack/utils.py
@@ -1,6 +1,9 @@
from django.core.exceptions import ImproperlyConfigured
-from django.utils.importlib import import_module
-from django.db import connection
+try:
+ from importlib import import_module
+except ImportError:
+ from django.utils.importlib import import_module
+from django.db import connection, transaction
from haystack.utils import get_identifier
@@ -23,21 +26,30 @@ def get_update_task(task_path=None):
return Task()
-def enqueue_task(action, instance):
+def enqueue_task(action, instance, **kwargs):
"""
Common utility for enqueing a task for the given action and
model instance.
"""
identifier = get_identifier(instance)
- kwargs = {}
+ options = {}
if settings.CELERY_HAYSTACK_QUEUE:
- kwargs['queue'] = settings.CELERY_HAYSTACK_QUEUE
+ options['queue'] = settings.CELERY_HAYSTACK_QUEUE
if settings.CELERY_HAYSTACK_COUNTDOWN:
- kwargs['countdown'] = settings.CELERY_HAYSTACK_COUNTDOWN
+ options['countdown'] = settings.CELERY_HAYSTACK_COUNTDOWN
+
task = get_update_task()
- if hasattr(connection, 'on_commit'):
+ task_func = lambda: task.apply_async((action, identifier), kwargs, **options)
+
+ if hasattr(transaction, 'on_commit'):
+ # Django 1.9 on_commit hook
+ transaction.on_commit(
+ task_func
+ )
+ elif hasattr(connection, 'on_commit'):
+ # Django-transaction-hooks
connection.on_commit(
- lambda: task.apply_async((action, identifier), {}, **kwargs)
+ task_func
)
else:
- task.apply_async((action, identifier), {}, **kwargs)
+ task_func()
diff --git a/docs/Makefile b/docs/Makefile
deleted file mode 100644
index 6e92558..0000000
--- a/docs/Makefile
+++ /dev/null
@@ -1,130 +0,0 @@
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS =
-SPHINXBUILD = sphinx-build
-PAPER =
-BUILDDIR = _build
-
-# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
-
-help:
- @echo "Please use \`make <target>' where <target> is one of"
- @echo " html to make standalone HTML files"
- @echo " dirhtml to make HTML files named index.html in directories"
- @echo " singlehtml to make a single large HTML file"
- @echo " pickle to make pickle files"
- @echo " json to make JSON files"
- @echo " htmlhelp to make HTML files and a HTML help project"
- @echo " qthelp to make HTML files and a qthelp project"
- @echo " devhelp to make HTML files and a Devhelp project"
- @echo " epub to make an epub"
- @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
- @echo " latexpdf to make LaTeX files and run them through pdflatex"
- @echo " text to make text files"
- @echo " man to make manual pages"
- @echo " changes to make an overview of all changed/added/deprecated items"
- @echo " linkcheck to check all external links for integrity"
- @echo " doctest to run all doctests embedded in the documentation (if enabled)"
-
-clean:
- -rm -rf $(BUILDDIR)/*
-
-html:
- $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-dirhtml:
- $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-singlehtml:
- $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
- @echo
- @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-pickle:
- $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
- @echo
- @echo "Build finished; now you can process the pickle files."
-
-json:
- $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
- @echo
- @echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
- $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
- @echo
- @echo "Build finished; now you can run HTML Help Workshop with the" \
- ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-qthelp:
- $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
- @echo
- @echo "Build finished; now you can run "qcollectiongenerator" with the" \
- ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
- @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/celery-haystack.qhcp"
- @echo "To view the help file:"
- @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/celery-haystack.qhc"
-
-devhelp:
- $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
- @echo
- @echo "Build finished."
- @echo "To view the help file:"
- @echo "# mkdir -p $$HOME/.local/share/devhelp/celery-haystack"
- @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/celery-haystack"
- @echo "# devhelp"
-
-epub:
- $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
- @echo
- @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo
- @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
- @echo "Run \`make' in that directory to run these through (pdf)latex" \
- "(use \`make latexpdf' here to do that automatically)."
-
-latexpdf:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo "Running LaTeX files through pdflatex..."
- make -C $(BUILDDIR)/latex all-pdf
- @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-text:
- $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
- @echo
- @echo "Build finished. The text files are in $(BUILDDIR)/text."
-
-man:
- $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
- @echo
- @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-changes:
- $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
- @echo
- @echo "The overview file is in $(BUILDDIR)/changes."
-
-linkcheck:
- $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
- @echo
- @echo "Link check complete; look for any errors in the above output " \
- "or in $(BUILDDIR)/linkcheck/output.txt."
-
-doctest:
- $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
- @echo "Testing of doctests in the sources finished, look at the " \
- "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/changelog.rst b/docs/changelog.rst
deleted file mode 100644
index 57eb5f2..0000000
--- a/docs/changelog.rst
+++ /dev/null
@@ -1,167 +0,0 @@
-Changelog
-=========
-
-v0.9 (2015-06-13)
------------------
-
-* Moved to Haystack GitHub org: https://github.com/django-haystack/celery-haystack
-
-* Fix handling the default Haystack backend alias, making it a list.
-
-* Added ``CELERY_HAYSTACK_QUEUE`` setting to define which Celery queue to use.
-
-* Added ``CELERY_HAYSTACK_COUNTDOWN`` setting to define when to start the
- indexing task after initially creating it.
-
-* Stop returning after after enqueing in the Haystack router to support
- multple routers.
-
-* Optionally support using django-transaction-hooks for improved transaction
- handling.
-
-* Instantiate update task class correctly.
-
-* Use Celery's task logger utility function.
-
-v0.8 (2014-07-31)
------------------
-
-* Fix bug when using multiple Haystack indizes
-
-* Fixed merge bug where primary key of object was cast to int
-
-* Add compatibility for Python 3.3, 3.4, Celery 3.X
-
-v0.7.2 (2013-03-23)
--------------------
-
-* Fixed import time issue with Haystack 2.X.
-
-* Minor fixes to the README.
-
-* Made signal processor compatible for subclassing for easier extensibility.
-
-v0.7.1 (2013-03-09)
--------------------
-
-* Fixed an installation issues with d2to1.
-
-v0.7 (2013-03-09)
------------------
-
-* **Backwards incompatible** change to support the new signal processor API
- in Haystack 2.X. To upgrade simply add this to your settings::
-
- HAYSTACK_SIGNAL_PROCESSOR = 'celery_haystack.signals.CelerySignalProcessor'
-
- Many thanks to Stefan Wehrmeyer for the help.
-
-* Simplified index class implementation.
-
-* Support multiple indexes in the task. Thanks, Stefan Wehrmeyer.
-
-* Use the exception handler of the task logger instead of the error handler
- when catching an exception.
-
-* Switched to d2to1_ for handling package metadata.
-
-.. _d2to1: http://pypi.python.org/pypi/d2to1
-
-v0.6.2 (2012-06-28)
--------------------
-
-* Fixed AttributeError in settings handling.
-
-v0.6.1 (2012-06-27)
--------------------
-
-* Fixed logging setup.
-
... 617 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/celery-haystack.git
More information about the Python-modules-commits
mailing list