def METHOD_NAME(sender, request, **kwargs):
    try:
        r = resolve(request.path_info)
    except:
        return
    urlname = r.url_name
    urlkwargs = r.kwargs
    if urlname.startswith('event.order'):
        key = 'order_{}_{}_{}_return_url'.format(urlkwargs.get('organizer', '-'), urlkwargs.get('event', '-'),
                                                 urlkwargs['order'])
        if urlname == 'event.order' and key in request.session:
            url = request.session.get(key)
            query = []
            storage = get_messages(request)
            for message in storage:
                if message.level == messages.ERROR:
                    query.append(('error', str(message)))
                elif message.level == messages.WARNING:
                    query.append(('warning', str(message)))
                if message.level == messages.INFO:
                    query.append(('info', str(message)))
                if message.level == messages.SUCCESS:
                    query.append(('success', str(message)))
            if query:
                if '?' in url:
                    url += '&' + urlencode(query)
                else:
                    url += '?' + urlencode(query)
            r = redirect(url)
            del request.session[key]
            return r
        elif urlname != 'event.order' and 'return_url' in request.GET:
            u = request.GET.get('return_url')
            if not sender.settings.returnurl_prefix:
                raise PermissionDenied('No return URL prefix set.')
            elif not u.startswith(sender.settings.returnurl_prefix):
                raise PermissionDenied('Invalid return URL.')
            request.session[key] = u