annotate core/services.py @ 943:cf9918328c64
Haystack tweaks for Django 1.7.7.
I had to upgrade to Haystack 2.3.1 to get it to work with Django
1.7.7. I also had to update the Xapian backend. But I ran into
problems.
On my laptop anyway (Ubuntu 14.0.4), xapian gets mad when search terms
are greater than 245 chars (or something) when indexing. So I created
a custom field that would simply omit terms greater than 64 chars and
used this field everywhere I previously used a CharField.
Secondly, the custom search form was broken now. Something changed in
the Xapian backend and exact searches stopped working. Fortunately the
auto_query (which I was using originally and broke during an upgrade)
started working again. So I cut the search form back over to doing an
auto_query. I kept the form the same (3 fields) because I didn't want
to change the form and I think it's better that way.
author |
Brian Neal <bgneal@gmail.com> |
date |
Wed, 13 May 2015 20:25:07 -0500 |
parents |
a423e8fd082d |
children |
|
rev |
line source |
bgneal@508
|
1 """
|
bgneal@508
|
2 This module provides a common way for the various apps to integrate with services
|
bgneal@508
|
3 that are installed at this site.
|
bgneal@508
|
4
|
bgneal@508
|
5 """
|
bgneal@508
|
6 from django.conf import settings
|
bgneal@508
|
7 import redis
|
bgneal@508
|
8
|
bgneal@508
|
9 # Redis connection and database settings
|
bgneal@508
|
10
|
bgneal@508
|
11 REDIS_HOST = getattr(settings, 'REDIS_HOST', 'localhost')
|
bgneal@508
|
12 REDIS_PORT = getattr(settings, 'REDIS_PORT', 6379)
|
bgneal@508
|
13 REDIS_DB = getattr(settings, 'REDIS_DB', 0)
|
bgneal@879
|
14 REDIS_SOCKET = getattr(settings, 'REDIS_UNIX_SOCKET', None)
|
bgneal@508
|
15
|
bgneal@508
|
16
|
bgneal@879
|
17 def get_redis_connection(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB,
|
bgneal@879
|
18 unix_socket_path=REDIS_SOCKET):
|
bgneal@508
|
19 """
|
bgneal@508
|
20 Create and return a Redis connection using the supplied parameters.
|
bgneal@508
|
21
|
bgneal@508
|
22 """
|
bgneal@879
|
23 if unix_socket_path:
|
bgneal@879
|
24 return redis.StrictRedis(unix_socket_path=unix_socket_path, db=db)
|
bgneal@519
|
25 return redis.StrictRedis(host=host, port=port, db=db)
|