Back to index

moin  1.9.0~rc2
Action.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - Create an action link
00004 
00005     @copyright: 2004, 2007 Johannes Berg <johannes@sipsolutions.net>
00006                 2007 by MoinMoin:ReimarBauer
00007     @license: GNU GPL, see COPYING for details.
00008 """
00009 
00010 from MoinMoin import wikiutil
00011 
00012 Dependencies = ["language"]
00013 
00014 
00015 def _get_valid_actions(macro):
00016     """ lists all valid actions """
00017     from MoinMoin import action
00018     # builtin
00019     actions_builtin = action.names
00020     # global
00021     actions_global = ([x for x in action.modules
00022                        if not x in macro.request.cfg.actions_excluded])
00023     # local
00024     actions_local = ([x for x in wikiutil.wikiPlugins('action', macro.cfg)
00025                       if not x in macro.request.cfg.actions_excluded])
00026 
00027     return actions_builtin + actions_global + actions_local
00028 
00029 def macro_Action(macro, action=u'show', text=None, _kwargs=None):
00030     _ = macro.request.getText
00031     if text is None:
00032         text = action
00033     if not _kwargs:
00034         _kwargs = {}
00035 
00036     text = _(text)
00037     if action in _get_valid_actions(macro):
00038         page = macro.formatter.page
00039         _kwargs['action'] = action
00040         url = page.url(macro.request, querystr=_kwargs)
00041         return ''.join([
00042             macro.formatter.url(1, url, css='action'),
00043             macro.formatter.text(text),
00044             macro.formatter.url(0),
00045         ])
00046     else:
00047         return macro.formatter.text(text)