def needs_mail(function):
    """
    Decorator to get the mail object
    """
    @wraps(function)
    def wrapper(request, mail_hash=None, *args, **kwargs):
        try:
            mail = Mail.objects.get(mail_hash=mail_hash)
        except __HOLE__:
            return HttpResponseRedirect('/')
        return function(request, mail=mail, *args, **kwargs)
    return wrapper
dataset/ETHPy150Open allink/pennyblack/pennyblack/views.py/needs_mail