lukaszb/django-guardian — Issue #54: Unexpected crash when checking for permission
Author: glibersat
Created: 2011-10-24 14:26:56+00:00
State: open

Hi,

While my users' permissions are correct, I get the following traceback when checking a permission for a given user. I can't reproduce it in the shell, but it always happen when run through a django view :

Traceback (most recent call last):

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)

File "/home/www/virtualenvs/imaginationforpeople.org/imaginationforpeople/apps/member/views.py", line 143, in profile_edit
if not current_user.has_perm('change_profile', profile):

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/contrib/auth/models.py", line 324, in has_perm
return _user_has_perm(self, perm, obj)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/contrib/auth/models.py", line 181, in _user_has_perm
backend.has_perm(user, perm, obj)):

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/guardian/backends.py", line 59, in has_perm
return check.has_perm(perm, obj)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/guardian/core.py", line 49, in has_perm
return perm in self.get_perms(obj)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/guardian/core.py", line 77, in get_perms
.values_list("codename"))))

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/db/models/query.py", line 514, in values_list
_fields=fields)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/db/models/query.py", line 754, in _clone
query = self.query.clone()

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/db/models/sql/query.py", line 247, in clone
obj.where = deepcopy(self.where, memo=memo)

File "/usr/lib/python2.6/copy.py", line 173, in deepcopy
y = copier(memo)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/utils/tree.py", line 61, in __deepcopy__
obj.children = deepcopy(self.children, memodict)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 228, in _deepcopy_list
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 173, in deepcopy
y = copier(memo)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/utils/tree.py", line 61, in __deepcopy__
obj.children = deepcopy(self.children, memodict)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 228, in _deepcopy_list
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 173, in deepcopy
y = copier(memo)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/utils/tree.py", line 61, in __deepcopy__
obj.children = deepcopy(self.children, memodict)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 228, in _deepcopy_list
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 173, in deepcopy
y = copier(memo)

File "/home/www/virtualenvs/imaginationforpeople.org/lib/python2.6/site-packages/django/utils/tree.py", line 61, in __deepcopy__
obj.children = deepcopy(self.children, memodict)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 228, in _deepcopy_list
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 235, in _deepcopy_tuple
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 235, in _deepcopy_tuple
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 235, in _deepcopy_tuple
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 235, in _deepcopy_tuple
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 235, in _deepcopy_tuple
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 235, in _deepcopy_tuple
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 235, in _deepcopy_tuple
y.append(deepcopy(a, memo))

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)

File "/usr/lib/python2.6/copy.py", line 162, in deepcopy
y = copier(x, memo)

File "/usr/lib/python2.6/copy.py", line 255, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/usr/lib/python2.6/copy.py", line 189, in deepcopy
y = _reconstruct(x, rv, 1, memo)

File "/usr/lib/python2.6/copy.py", line 323, in _reconstruct
y = callable(*args)

File "/usr/lib/python2.6/copy_reg.py", line 93, in __newobj__
return cls.__new__(cls, *args)

TypeError: instancemethod expected at least 2 arguments, got 0

My backends are the following:

AUTHENTICATION_BACKENDS = (
'userena.backends.UserenaAuthenticationBackend',
'guardian.backends.ObjectPermissionBackend',
'django.contrib.auth.backends.ModelBackend',
)

And my versions:
Django 1.3.1, Guardian 1.0.3

Thank you !

Guillaume