Mercurial > public > sg101
annotate ygroup/search_indexes.py @ 629:f4c043cf55ac
Wiki integration. Requests don't always have sessions.
In particular this occurs when a request is made without a trailing slash.
The Common middleware redirects when this happens, and the middleware
process_request() processing stops before a session can get added.
So just set an attribute on the request object for each operation.
This seemed weird to me at first, but there are plenty of examples of this
in the Django code base already.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 13 Nov 2012 13:50:06 -0600 |
parents | ee87ea74d46b |
children | ad53d929281a |
rev | line source |
---|---|
bgneal@323 | 1 """ |
bgneal@323 | 2 Haystack search index for the Yahoo Group archives application. |
bgneal@323 | 3 |
bgneal@323 | 4 """ |
bgneal@323 | 5 from haystack.indexes import * |
bgneal@323 | 6 from haystack import site |
bgneal@469 | 7 from custom_search.indexes import CondQueuedSearchIndex |
bgneal@323 | 8 |
bgneal@323 | 9 from ygroup.models import Post |
bgneal@323 | 10 |
bgneal@323 | 11 |
bgneal@467 | 12 class PostIndex(CondQueuedSearchIndex): |
bgneal@323 | 13 text = CharField(document=True, use_template=True) |
bgneal@323 | 14 pub_date = DateTimeField(model_attr='creation_date') |
bgneal@323 | 15 |
bgneal@323 | 16 def get_updated_field(self): |
bgneal@323 | 17 return 'creation_date' |
bgneal@323 | 18 |
bgneal@323 | 19 |
bgneal@323 | 20 site.register(Post, PostIndex) |