def _generic_view(message_method, fail_signal, request, message_id, dispatch_id, hashed, redirect_to=None):

    if redirect_to is None:
        redirect_to = '/'

    try:
        dispatch = Dispatch.objects.select_related('message').get(pk=dispatch_id)
        if int(message_id) != dispatch.message_id:
            raise ValueError()
        message = dispatch.message
    except (Dispatch.DoesNotExist, __HOLE__):
        pass
    else:
        try:
            message_type = message.get_type()
            expected_hash = message_type.get_dispatch_hash(dispatch_id, message_id)

            method = getattr(message_type, message_method)
            return method(
                request, message, dispatch,
                hash_is_valid=(expected_hash == hashed),
                redirect_to=redirect_to
            )
        except UnknownMessageTypeError:
            pass

    fail_signal.send(None, request=request, message=message_id, dispatch=dispatch_id)

    return redirect(redirect_to)
dataset/ETHPy150Open idlesign/django-sitemessage/sitemessage/views.py/_generic_view