I'm trying to write a simple view decorator that does some permission checking based on an ID passed as part of the URL and the authenticated user. Some relevant code:
The decorator: def owns_item(failure_redirect_url='/'): def check_ownership(method): def _wrapper(request, **kwargs): try: opb_id=request.user.get_profile().opb_id csi = kwargs.get('csi', None) if opb_id and csi and models.has_permission(opb_id, csi): return method(*args, **kwargs) except Exception, e: logger.debug("Exception checking cloud server ownership: %s", str(e)) return HttpResponseRedirect(failure_redirect_url) _wrapper.__dict__=method.__dict__ _wrapper.__doc__=method.__doc__ return _wrapper return check_ownership And using it: @owns_item def do_something(request, csi=None): """This is my view code""" The problem is that check_ownership() is not being called with "do_something" as its argument. It is being called with the WSGIRequest that I would expect _wrapper() to be getting called with. Because of that, I don't have a way to continue the method chain because I don't have a method to call. Please, somebody tell me, what happened to my method? Oh, yeah, Python 2.4.3 and Django 1.1.1. Thanks. tj -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.