You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I experienced some problems in admin site when I tried to use django-caching for my app. ( TypeError: can't pickle instancemethod objects ) when tried to view cached model record.
All works like a charm, but opening cached record in admin site fails :(
Object that caching tried to cache and fails is CachingManyToManyField with values [7L, 11L].
Latest SVN Django 1.1 beta + mysql4.23 + python2.6 + memcache on WinXP sp3 under Django built-in dev server.
See http://paste.pocoo.org/show/119491/
Traceback (most recent call last):
File "d:\python26\Lib\site-packages\django\core\servers\basehttp.py", line 636, in call
return self.application(environ, start_response)
File "D:\Python26\lib\site-packages\django\core\handlers\wsgi.py", line 241, in call
response = self.get_response(request)
File "D:\Python26\Lib\site-packages\django\core\handlers\base.py", line 134, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
File "D:\Python26\Lib\site-packages\django\core\handlers\base.py", line 154, in handle_uncaught_exception
return debug.technical_500_response(request, _exc_info)
File "D:\Python26\Lib\site-packages\django\core\handlers\base.py", line 92, in get_response
response = callback(request, *callback_args, *_callback_kwargs)
File "d:\python26\Lib\site-packages\django\contrib\admin\sites.py", line 480, in root
return self.model_page(request, _url.split('/', 2))
File "D:\Python26\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, *_kwargs)
File "d:\python26\Lib\site-packages\django\contrib\admin\sites.py", line 499, in model_page
return admin_obj(request, rest_of_url)
File "d:\python26\Lib\site-packages\django\contrib\admin\options.py", line 1094, in call
return self.change_view(request, unquote(url))
File "D:\Python26\lib\site-packages\django\db\transaction.py", line 240, in _commit_on_success
res = func(_args, *_kw)
File "d:\python26\Lib\site-packages\django\contrib\admin\options.py", line 839, in change_view
form = ModelForm(instance=obj)
File "D:\Python26\Lib\site-packages\django\forms\models.py", line 222, in init
object_data = model_to_dict(instance, opts.fields, opts.exclude)
File "D:\Python26\Lib\site-packages\django\forms\models.py", line 140, in model_to_dict
data[f.name] = [obj.pk for obj in f.value_from_object(instance)]
File "d:\python26\Lib\site-packages\django\db\models\fields\related.py", line 940, in value_from_object
return getattr(obj, self.attname).all()
File "D:\Python26\Scripts\gurt\apps\caching\fields.py", line 73, in all
cache.add(key, pk_list, CACHE_DURATION)
File "D:\Python26\Scripts\gurt\apps\caching\cache.py", line 16, in add
return self._cache.add(smart_str(key), value, timeout, min_compress_len)
File "build\bdist.win32\egg\memcache.py", line 443, in add
return self._set("add", key, val, time, min_compress_len)
File "build\bdist.win32\egg\memcache.py", line 681, in _set
store_info = self._val_to_store_info(val, min_compress_len)
File "build\bdist.win32\egg\memcache.py", line 654, in _val_to_store_info
pickler.dump(val)
File "d:\Python26\Lib\copy_reg.py", line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.name
TypeError: can't pickle instancemethod objects
The text was updated successfully, but these errors were encountered:
Strange. Seems an instance method is being sent to the cache somehow, but that shouldn't happen since the code only caches a list of primary keys. Any info on how I can reproduce it?
I've created a sample quick and dirty error project based on your django-caching here: http://bitbucket.org/zam/django-caching-errorexample/
Go to http://127.0.0.1:8000/admin/ (login: admin, pass:123) and try to add new article. It will fail when you press Save button.
I think that problem was related to my models, but it seems to be related to the django built-in admin contrib. So you can ignore _errormodels.py - it's almost the same as yours (one many2many link to other table).
I experienced some problems in admin site when I tried to use django-caching for my app. ( TypeError: can't pickle instancemethod objects ) when tried to view cached model record.
All works like a charm, but opening cached record in admin site fails :(
Object that caching tried to cache and fails is CachingManyToManyField with values [7L, 11L].
Latest SVN Django 1.1 beta + mysql4.23 + python2.6 + memcache on WinXP sp3 under Django built-in dev server.
See http://paste.pocoo.org/show/119491/
Traceback (most recent call last):
File "d:\python26\Lib\site-packages\django\core\servers\basehttp.py", line 636, in call
return self.application(environ, start_response)
File "D:\Python26\lib\site-packages\django\core\handlers\wsgi.py", line 241, in call
response = self.get_response(request)
File "D:\Python26\Lib\site-packages\django\core\handlers\base.py", line 134, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
File "D:\Python26\Lib\site-packages\django\core\handlers\base.py", line 154, in handle_uncaught_exception
return debug.technical_500_response(request, _exc_info)
File "D:\Python26\Lib\site-packages\django\core\handlers\base.py", line 92, in get_response
response = callback(request, *callback_args, *_callback_kwargs)
File "d:\python26\Lib\site-packages\django\contrib\admin\sites.py", line 480, in root
return self.model_page(request, _url.split('/', 2))
File "D:\Python26\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, *_kwargs)
File "d:\python26\Lib\site-packages\django\contrib\admin\sites.py", line 499, in model_page
return admin_obj(request, rest_of_url)
File "d:\python26\Lib\site-packages\django\contrib\admin\options.py", line 1094, in call
return self.change_view(request, unquote(url))
File "D:\Python26\lib\site-packages\django\db\transaction.py", line 240, in _commit_on_success
res = func(_args, *_kw)
File "d:\python26\Lib\site-packages\django\contrib\admin\options.py", line 839, in change_view
form = ModelForm(instance=obj)
File "D:\Python26\Lib\site-packages\django\forms\models.py", line 222, in init
object_data = model_to_dict(instance, opts.fields, opts.exclude)
File "D:\Python26\Lib\site-packages\django\forms\models.py", line 140, in model_to_dict
data[f.name] = [obj.pk for obj in f.value_from_object(instance)]
File "d:\python26\Lib\site-packages\django\db\models\fields\related.py", line 940, in value_from_object
return getattr(obj, self.attname).all()
File "D:\Python26\Scripts\gurt\apps\caching\fields.py", line 73, in all
cache.add(key, pk_list, CACHE_DURATION)
File "D:\Python26\Scripts\gurt\apps\caching\cache.py", line 16, in add
return self._cache.add(smart_str(key), value, timeout, min_compress_len)
File "build\bdist.win32\egg\memcache.py", line 443, in add
return self._set("add", key, val, time, min_compress_len)
File "build\bdist.win32\egg\memcache.py", line 681, in _set
store_info = self._val_to_store_info(val, min_compress_len)
File "build\bdist.win32\egg\memcache.py", line 654, in _val_to_store_info
pickler.dump(val)
File "d:\Python26\Lib\copy_reg.py", line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.name
TypeError: can't pickle instancemethod objects
The text was updated successfully, but these errors were encountered: