django-cbv
django-cbv copied to clipboard
TypeError: can't pickle function objects with per-site cache
From @Kooludo on sorl/django-cbv:
Hi there. I'm getting an error "TypeError: can't pickle function objects" when I attempt to use django-cbv with Django's per site caching middleware (django.middleware.cache.FetchFromCacheMiddleware and django.middleware.cache.UpdateCacheMiddleware).
In my case it seems like it's failing on attempting to pickle an object of type cbv.http.TemplateResponse. I've tried with memcache and locmem backends.
Is this a known issue. Are there any workarounds?
Traceback (most recent call last):
File "/home/ludo/.virtualenvs/myproject-env/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 280, in run
self.result = application(self.environ, self.start_response)
File "/home/ludo/.virtualenvs/myproject-env/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 674, in __call__
return self.application(environ, start_response)
File "/home/ludo/.virtualenvs/myproject-env/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 252, in __call__
response = middleware_method(request, response)
File "/home/ludo/.virtualenvs/myproject-env/lib/python2.6/site-packages/django/middleware/cache.py", line 105, in process_response
cache.set(cache_key, response, timeout)
File "/home/ludo/.virtualenvs/myproject-env/lib/python2.6/site-packages/django/core/cache/backends/locmem.py", line 86, in set
self._set(key, pickle.dumps(value), timeout)
File "/home/ludo/.virtualenvs/myproject-env/lib/python2.6/copy_reg.py", line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle function objects
It's happening with two different apps using cbv generic views. It's unable to pickle an object of type cbv.http.TemplateResponse.
I'm also using Django-CMS, so wonder if that could be messing with something?