google-code-export / djapian

Automatically exported from code.google.com/p/djapian
Other
1 stars 0 forks source link

result set cannot be stored in session #89

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Cant store search result in session:

The following two lines of code don't work:

result = complete_indexer.search(query).prefetch()
request.session['search_result'] = result

Traceback (most recent call last):

  File
"/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py",
line 279, in run
    self.result = application(self.environ, self.start_response)

  File
"/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py",
line 651, in __call__
    return self.application(environ, start_response)

  File
"/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line
245, in __call__
    response = middleware_method(request, response)

  File
"/usr/local/lib/python2.6/dist-packages/django/contrib/sessions/middleware.py",
line 36, in process_response
    request.session.save()

  File
"/usr/local/lib/python2.6/dist-packages/django/contrib/sessions/backends/db.py",
line 53, in save
    session_data = self.encode(self._get_session(no_load=must_create)),

  File
"/usr/local/lib/python2.6/dist-packages/django/contrib/sessions/backends/base.py
",
line 88, in encode
    pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)

PicklingError: Can't pickle <type 'PySwigObject'>: attribute lookup
__builtin__.PySwigObject failed

Original issue reported on code.google.com by saraf.saurabh on 10 Oct 2009 at 2:16

GoogleCodeExporter commented 9 years ago
Hmmm... I think It is Xapian python binding limitation. I''ll try to do some 
research
about it.

Original comment by daevaorn on 10 Oct 2009 at 2:33

GoogleCodeExporter commented 9 years ago
What version of python, djapian, xapian and python-binding do you use?

Original comment by daevaorn on 11 Oct 2009 at 1:28

GoogleCodeExporter commented 9 years ago
python 2.6.2
djapian 2.3
xapian python-bindings: 1.0.7

I am using debian ubuntu package of xapian and python bindings, just in case if 
you
need this information.

Also, if there is any work-around to this problem by changing the above 
versions, do
let me know.

Original comment by saraf.saurabh on 11 Oct 2009 at 6:02

GoogleCodeExporter commented 9 years ago
I'm using almost the same configuration and cannot reproduce such error

Original comment by daevaorn on 11 Oct 2009 at 6:09

GoogleCodeExporter commented 9 years ago
Thanks. So I guess this should be a problem on my side. Will update if I have 
any news.

Original comment by saraf.saurabh on 11 Oct 2009 at 6:12

GoogleCodeExporter commented 9 years ago
I still cant figure out the problem. I believe its something related to this 
ticket:
http://code.djangoproject.com/ticket/7813

However I have found a quick work-around. Slicing the queryset does the trick:

result = complete_indexer.search(query).prefetch()
request.session['search_result'] = result[0:]

Original comment by saraf.saurabh on 12 Oct 2009 at 6:18

GoogleCodeExporter commented 9 years ago

Original comment by daevaorn on 13 Dec 2009 at 9:06