Skip to content

Commit 0387801

Browse files
committed
Merge branch 'release/0.8'
2 parents 6283eda + ec88bd8 commit 0387801

File tree

9 files changed

+73
-32
lines changed

9 files changed

+73
-32
lines changed

.travis.yml

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,50 @@ language: python
22
python:
33
- "2.6"
44
- "2.7"
5+
- "3.3"
6+
- "3.4"
57
before_install:
68
- export DJANGO_SETTINGS_MODULE=celery_haystack.test_settings
79
install:
810
- pip install -e .
9-
- pip install -r requirements/$HAYSTACK.txt Django==$DJANGO
11+
- pip install -r requirements/$HAYSTACK.txt $DJANGO
1012
before_script:
1113
- flake8 celery_haystack --ignore=E501
1214
script:
1315
- coverage run --branch --source=celery_haystack `which django-admin.py` test celery_haystack
1416
- coverage report --omit=celery_haystack/test*
1517
env:
16-
- DJANGO=1.3.7 HAYSTACK=v1
17-
- DJANGO=1.3.7 HAYSTACK=v2
18-
- DJANGO=1.4.5 HAYSTACK=v1
19-
- DJANGO=1.4.5 HAYSTACK=v2
20-
- DJANGO=1.5 HAYSTACK=v1
21-
- DJANGO=1.5 HAYSTACK=v2
18+
- DJANGO="Django==1.4.13" HAYSTACK=v1
19+
- DJANGO="Django==1.4.13" HAYSTACK=v2
20+
- DJANGO="Django==1.5.8" HAYSTACK=v1
21+
- DJANGO="Django==1.5.8" HAYSTACK=v2
22+
- DJANGO="Django==1.6.5" HAYSTACK=v1
23+
- DJANGO="Django==1.6.5" HAYSTACK=v2
24+
- DJANGO="https://www.djangoproject.com/download/1.7c2/tarball/" HAYSTACK=v1
25+
- DJANGO="https://www.djangoproject.com/download/1.7c2/tarball/" HAYSTACK=v2
26+
matrix:
27+
exclude:
28+
- env: DJANGO="Django==1.4.13" HAYSTACK=v1
29+
python: "3.3"
30+
- env: DJANGO="Django==1.4.13" HAYSTACK=v2
31+
python: "3.3"
32+
- env: DJANGO="Django==1.5.8" HAYSTACK=v1
33+
python: "3.3"
34+
- env: DJANGO="Django==1.6.5" HAYSTACK=v1
35+
python: "3.3"
36+
- env: DJANGO="Django==1.4.13" HAYSTACK=v1
37+
python: "3.4"
38+
- env: DJANGO="Django==1.4.13" HAYSTACK=v2
39+
python: "3.4"
40+
- env: DJANGO="Django==1.5.8" HAYSTACK=v1
41+
python: "3.4"
42+
- env: DJANGO="Django==1.6.5" HAYSTACK=v1
43+
python: "3.4"
44+
- env: DJANGO="https://www.djangoproject.com/download/1.7c2/tarball/" HAYSTACK=v1
45+
python: "2.6"
46+
- env: DJANGO="https://www.djangoproject.com/download/1.7c2/tarball/" HAYSTACK=v2
47+
python: "2.6"
48+
- env: DJANGO="https://www.djangoproject.com/download/1.7c2/tarball/" HAYSTACK=v1
49+
python: "3.3"
50+
- env: DJANGO="https://www.djangoproject.com/download/1.7c2/tarball/" HAYSTACK=v1
51+
python: "3.4"

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ deleting objects in a Haystack_ search index.
1212
Requirements
1313
------------
1414

15-
* Django 1.2+
15+
* Django 1.4+
1616
* Haystack_ `1.2.X`_ *or* `2.X`_
17-
* Celery_ 2.X
17+
* Celery_ 3.X
1818

1919
You also need to install your choice of one of the supported search engines
2020
for Haystack and one of the supported backends for Celery.
2121

22+
2223
.. _Haystack: http://haystacksearch.org
2324
.. _`1.2.X`: http://pypi.python.org/pypi/django-haystack/1.2.5
2425
.. _`2.X`: https://github.com/toastdriven/django-haystack/tree/master

celery_haystack/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.7.2'
1+
__version__ = '0.8'
22

33

44
def version_hook(config):

celery_haystack/tasks.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from haystack import site
1414
from haystack.exceptions import NotRegistered as IndexNotFoundException # noqa
1515
legacy = True
16-
except ImportError, e:
16+
except ImportError as e:
1717
raise ImproperlyConfigured("Haystack couldn't be imported: %s" % e)
1818

1919
if settings.CELERY_HAYSTACK_TRANSACTION_SAFE and not getattr(settings, 'CELERY_ALWAYS_EAGER', False):
@@ -67,7 +67,7 @@ def get_instance(self, model_class, pk, **kwargs):
6767
logger = self.get_logger(**kwargs)
6868
instance = None
6969
try:
70-
instance = model_class._default_manager.get(pk=int(pk))
70+
instance = model_class._default_manager.get(pk=pk)
7171
except model_class.DoesNotExist:
7272
logger.error("Couldn't load %s.%s.%s. Somehow it went missing?" %
7373
(model_class._meta.app_label.lower(),
@@ -83,22 +83,16 @@ def get_indexes(self, model_class, **kwargs):
8383
try:
8484
if legacy:
8585
index_holder = site
86-
yield index_holder.get_index(model_class)
86+
yield index_holder.get_index(model_class), self.using
8787
else:
8888
using_backends = connection_router.for_write(**{'models': [model_class]})
8989
for using in using_backends:
9090
index_holder = connections[using].get_unified_index()
91-
yield index_holder.get_index(model_class)
91+
yield index_holder.get_index(model_class), using
9292
except IndexNotFoundException:
9393
raise ImproperlyConfigured("Couldn't find a SearchIndex for %s." %
9494
model_class)
9595

96-
def get_handler_options(self, **kwargs):
97-
options = {}
98-
if legacy:
99-
options['using'] = self.using
100-
return options
101-
10296
def run(self, action, identifier, **kwargs):
10397
"""
10498
Trigger the actual index handler depending on the
@@ -115,24 +109,22 @@ def run(self, action, identifier, **kwargs):
115109

116110
# Then get the model class for the object path
117111
model_class = self.get_model_class(object_path, **kwargs)
118-
for current_index in self.get_indexes(model_class, **kwargs):
112+
for current_index, using in self.get_indexes(model_class, **kwargs):
119113
current_index_name = ".".join([current_index.__class__.__module__,
120114
current_index.__class__.__name__])
121115

122116
if action == 'delete':
123117
# If the object is gone, we'll use just the identifier
124118
# against the index.
125119
try:
126-
handler_options = self.get_handler_options(**kwargs)
127-
current_index.remove_object(identifier, **handler_options)
128-
except Exception, exc:
120+
current_index.remove_object(identifier, using=using)
121+
except Exception as exc:
129122
logger.exception(exc)
130123
self.retry(exc=exc)
131124
else:
132125
msg = ("Deleted '%s' (with %s)" %
133126
(identifier, current_index_name))
134127
logger.debug(msg)
135-
return msg
136128
elif action == 'update':
137129
# and the instance of the model class with the pk
138130
instance = self.get_instance(model_class, pk, **kwargs)
@@ -144,16 +136,14 @@ def run(self, action, identifier, **kwargs):
144136
# Call the appropriate handler of the current index and
145137
# handle exception if neccessary
146138
try:
147-
handler_options = self.get_handler_options(**kwargs)
148-
current_index.update_object(instance, **handler_options)
149-
except Exception, exc:
139+
current_index.update_object(instance, using=using)
140+
except Exception as exc:
150141
logger.exception(exc)
151142
self.retry(exc=exc)
152143
else:
153144
msg = ("Updated '%s' (with %s)" %
154145
(identifier, current_index_name))
155146
logger.debug(msg)
156-
return msg
157147
else:
158148
logger.error("Unrecognized action '%s'. Moving on..." % action)
159149
raise ValueError("Unrecognized action %s" % action)

celery_haystack/test_settings.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import os
22

3+
import django
4+
5+
from celery import Celery
6+
7+
app = Celery('celery_haystack')
8+
app.config_from_object('django.conf:settings')
9+
10+
311
DEBUG = True
412

513
TEST_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tests'))
@@ -26,7 +34,8 @@
2634
CELERYD_LOG_LEVEL = "DEBUG"
2735
CELERY_DEFAULT_QUEUE = "celery-haystack"
2836

29-
TEST_RUNNER = 'discover_runner.DiscoverRunner'
37+
if django.VERSION < (1, 6):
38+
TEST_RUNNER = 'discover_runner.DiscoverRunner'
3039

3140
if os.environ.get('HAYSTACK') == 'v1':
3241
HAYSTACK_SITECONF = 'celery_haystack.tests.search_sites'

celery_haystack/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def get_update_task(task_path=None):
1111
module, attr = import_path.rsplit('.', 1)
1212
try:
1313
mod = import_module(module)
14-
except ImportError, e:
14+
except ImportError as e:
1515
raise ImproperlyConfigured('Error importing module %s: "%s"' %
1616
(module, e))
1717
try:

docs/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
v0.8 (2014-07-31)
5+
-------------------
6+
7+
* Fix bug when using multiple Haystack indizes
8+
9+
* Fixed merge bug where primary key of object was cast to int
10+
11+
* Add compatibility for Python 3.3, 3.4, Celery 3.X
12+
413
v0.7.2 (2013-03-23)
514
-------------------
615

requirements/v1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ django-discover-runner
22
django-haystack==1.2.7
33
django-celery
44
celery
5-
Whoosh
5+
whoosh<2.5
66
flake8
77
coverage

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ classifier =
2121
Programming Language :: Python
2222
Programming Language :: Python :: 2.6
2323
Programming Language :: Python :: 2.7
24+
Programming Language :: Python :: 3.3
25+
Programming Language :: Python :: 3.4
2426
Topic :: Utilities
2527
requires-dist =
2628
django-appconf>=0.4.1

0 commit comments

Comments
 (0)