On Mon, Jun 28, 2010 at 12:07 PM, kernel1983 <kernel1...@gmail.com> wrote:
> There is exception Http404 in the system.
>
> During django programming, we often need to do some data valid:
>
> def A(request):
>    valid()
>    return render_to_response(...)
>
> def B(request):
>    valid()
>    return render_to_response(...)
> ...
>
> def valid():
>    throw Http301(url)

from django.shortcuts import redirect

def valid(method):
    def decorated(request, *args, **kwargs):
        if not 'Tim' in request.user.called_by_some_people():
            return redirect('some-view', ...)
        return method(request, *args, **kwargs)
    return decorated

@valid
def A(request):
    return render_to_response(...)

@valid
def B(request):
    return render_to_response(...)

print 'There you go.'

-- 
Patryk Zawadzki

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to