'Create a timeout-related \'forbidden_actions\' for event-collector.
action_name: the action taken by a user in timeout
details_text: this provides more details about the action
target: The intended item the action was to be taken on
target_fullname: The fullname used to convert to a target
subreddit: The Subreddit the action was taken in. If target is of the
type Subreddit, then this won\'t be passed in
request, context: Should be pylons.request & pylons.c respectively;'

@squelch_exceptions
def timeout_forbidden_event(self, action_name, details_text, target=None, target_fullname=None, subreddit=None, request=None, context=None):

    if (not action_name):
        request_vars = request.environ['pylons.routes_dict']
        action_name = request_vars.get('action_name')
        if (action_name == 'vote'):
            direction = int(request.POST.get('dir', 0))
            if (direction == 1):
                action_name = 'upvote'
            elif (direction == (-1)):
                action_name = 'downvote'
            else:
                action_name = 'clearvote'
        elif (action_name in ('set_contest_mode', 'set_subreddit_sticky')):
            action_name = action_name.replace('_', '')
            if (request.POST.get('state') == 'False'):
                action_name = ('un' + action_name)
        elif (action_name == 'set_suggested_sort'):
            action_name = action_name.replace('_', '')
            if (request.POST.get('sort') in ('', 'clear')):
                action_name = ('un' + action_name)
        elif (action_name == 'spamlisting'):
            action_name = 'pageview'
            details_text = request_vars.get('location')
        elif (action_name == 'clearflairtemplates'):
            action_name = 'editflair'
            details_text = 'flair_clear_template'
        elif (action_name in ('flairconfig', 'flaircsv', 'flairlisting')):
            details_text = action_name.replace('flair', 'flair_')
            action_name = 'editflair'
    if (not target):
        if (not target_fullname):
            if (action_name in ('wiki_settings', 'wiki_edit')):
                target = context.site
            elif (action_name in 'wiki_allow_editor'):
                target = Account._by_name(request.POST.get('username'))
            elif (action_name in ('delete_sr_header', 'delete_sr_icon', 'delete_sr_banner')):
                details_text = ('%s' % action_name.replace('ete_sr', ''))
                action_name = 'editsettings'
                target = context.site
            elif (action_name in ('bannedlisting', 'mutedlisting', 'wikibannedlisting', 'wikicontributorslisting')):
                target = context.site
        if target_fullname:
            from r2.models import Thing
            target = Thing._by_fullname(target_fullname, return_dict=False, data=True)
    event = Event(topic='forbidden_actions', event_type=('ss.forbidden_%s' % action_name), request=request, context=context)
    event.add('details_text', details_text)
    event.add('process_notes', 'IN_TIMEOUT')
    from r2.models import Comment, Link, Subreddit
    if (not subreddit):
        if isinstance(context.site, Subreddit):
            subreddit = context.site
        elif isinstance(target, (Comment, Link)):
            subreddit = target.subreddit_slow
        elif isinstance(target, Subreddit):
            subreddit = target
    event.add_subreddit_fields(subreddit)
    event.add_target_fields(target)
    self.save_event(event)
