I'm trying to write a custom view decorator that takes a parameter, and I can't for the life of me figure out how to pass the parameter. I've tried the nested function pattern, the class with __init__ and __call__ methods pattern, and I always run into the same basic error. It either says I have to many parameters (professional_only expects 1 param but got 2) or too few parameters (expects only 1 but got 2) or in it's current state, says that NoneType or the view function is not callable?!?
Here's a dpaste dump - http://dpaste.org/azgn/ and the current form: def professional_only(active): """ Decorator that verifies user is professional, and implicitly that he is logged in.""" def _check_status(view_func): def _dec(request, *args, **kwargs): if request.user.is_authenticated(): profil = request.user.profile if profil.is_professional_member(): if active: try: entreprise_statut = Entreprise.objects.get (administrateur=request.user).statut if entreprise_statut == 'AC': return view_func(request, *args, **kwargs) except: pass else: return view_func(request, *args, **kwargs) return HttpResponseRedirect(reverse ('pro_access_only')) else: url = '%s?%s=%s' % (settings.LOGIN_URL, REDIRECT_FIELD_NAME, urllib.quote(request.get_full_path())) return HttpResponseRedirect(url) return _check_status Thanks in advance for your help, Sam --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---