Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.macro.WikiConfig Namespace Reference

Functions

def macro_WikiConfig

Variables

list Dependencies = ['user']
 generates_headings = True

Function Documentation

Definition at line 10 of file WikiConfig.py.

00010 
00011 def macro_WikiConfig(macro):
00012     request = macro.request
00013     _ = request.getText
00014     f = macro.request.formatter
00015     ret = []
00016 
00017     if not request.user or not request.user.isSuperUser():
00018         return ''
00019 
00020     settings = {}
00021     for groupname in multiconfig.options:
00022         heading, desc, opts = multiconfig.options[groupname]
00023         for name, default, description in opts:
00024             name = groupname + '_' + name
00025             if isinstance(default, multiconfig.DefaultExpression):
00026                 default = default.value
00027             settings[name] = default
00028     for groupname in multiconfig.options_no_group_name:
00029         heading, desc, opts = multiconfig.options_no_group_name[groupname]
00030         for name, default, description in opts:
00031             if isinstance(default, multiconfig.DefaultExpression):
00032                 default = default.value
00033             settings[name] = default
00034 
00035     ret.extend([
00036         f.heading(1, 1, id='current_config'),
00037         f.text(_("Wiki configuration")),
00038         f.heading(0, 1),
00039         f.paragraph(1),
00040         _("This table shows all settings in this wiki that do not have default values. "
00041           "Settings that the configuration system doesn't know about are shown in ''italic'', "
00042           "those may be due to third-party extensions needing configuration or settings that "
00043           "were removed from Moin.",
00044           wiki=True),
00045         f.paragraph(0),
00046     ])
00047     ret.extend([
00048         f.table(1),
00049         f.table_row(1),
00050         f.table_cell(1), f.strong(1), f.text(_('Variable name')), f.strong(0), f.table_cell(0),
00051         f.table_cell(1), f.strong(1), f.text(_('Setting')), f.strong(0), f.table_cell(0),
00052         f.table_row(0),
00053     ])
00054 
00055     def iter_vnames(cfg):
00056         dedup = {}
00057         for name in cfg.__dict__:
00058             dedup[name] = True
00059             yield name, cfg.__dict__[name]
00060         for cls in cfg.__class__.mro():
00061             if cls == multiconfig.ConfigFunctionality:
00062                 break
00063             for name in cls.__dict__:
00064                 if not name in dedup:
00065                     dedup[name] = True
00066                     yield name, cls.__dict__[name]
00067 
00068     found = []
00069     for vname, value in iter_vnames(request.cfg):
00070         if hasattr(multiconfig.ConfigFunctionality, vname):
00071             continue
00072         if vname in settings and settings[vname] == value:
00073             continue
00074         found.append((vname, value))
00075     found.sort()
00076     for vname, value in found:
00077         vname = f.text(vname)
00078         if not vname in settings:
00079             vname = f.emphasis(1) + vname + f.emphasis(0)
00080         vtxt = '%r' % (value, )
00081         ret.extend([
00082             f.table_row(1),
00083             f.table_cell(1), vname, f.table_cell(0),
00084             f.table_cell(1), f.code(1, css="backtick"), f.text(vtxt), f.code(0), f.table_cell(0),
00085             f.table_row(0),
00086         ])
00087     ret.append(f.table(0))
00088 
00089     return ''.join(ret)

Variable Documentation

Definition at line 7 of file WikiConfig.py.

Definition at line 8 of file WikiConfig.py.