アプリケーションにロール ベースのアクセス許可を実装しようとしています。ユーザーロールのセットを渡すことができるデコレータ role_required があり、そのロールを持つユーザーのみがそのビューにアクセスできます。ユーザーにロールを適切に割り当てましたが、今はそのことを示す AttributeError を取得しています'Role' object has no attribute '__name__'
views.pyファイル:
m_role_required = method_decorator(role_required)
class AddProposal(FormView):
    @m_role_required(roles.space_admin)
    def dispatch(self, *args, **kwargs):
        return super(AddProposal, self).dispatch(*args, **kwargs)
デコレータrole_required:
from django.contrib.auth.decorators import user_passes_test
def role_required(*roles):
    def check_role(user):
        return getattr(user, 'role', None) in roles
    return user_passes_test(check_role)
Roleクラス:
class Roles(object):
    _roles_dict = None
    @property
    def roles_dict(self):
        if self._roles_dict is None:
            self._roles_dict = {}
            for item in self._config:
                if isinstance(item, basestring):
                    # An item like 'manager'
                    self._roles_dict[item] = None
                else:
                    # Anything else
                    raise ImproperlyConfigured(_INCORRECT_ARGS)
        return self._roles_dict
    @property
    def choices(self):
        return [(role, role) for role in self.roles_dict.keys()]
    def __init__(self, config=None):
        self._config = config or getattr(settings, 'USER_ROLES', ())
    def __getattr__(self, name):
        if name in self.roles_dict.keys():
            return Role(name=name)
        else:
            raise AttributeError("No such role exists '%s'" % name)
roles = Roles()
このエラーが発生する理由を見つけることができません。誰でも助けることができます。これでトレースバックを追加させてください。
環境:
Request Method: GET
Request URL: http://127.0.0.1:8000/en-gb/spaces/bithin/proposal/add/
Traceback:
  48. class AddProposal(FormView):
File "/home/bithin/gsoc/week3/e-cidadania/src/apps/ecidadania/proposals/views.py" in AddProposal
  78.     @m_role_required(roles.space_admin)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _dec
  34.         update_wrapper(_wrapper, func)
File "/usr/lib/python2.7/functools.py" in update_wrapper
  33.         setattr(wrapper, attr, getattr(wrapped, attr))
Exception Type: AttributeError at /en-gb/spaces/bithin/proposal/add/
Exception Value: 'Role' object has no attribute '__name__'