changeset 3748:dc917a577d38

add multiconfig.DefaultExpression for documentation this allows showing the actual expression used as the default rather than using '%r', use sparingly
author Johannes Berg <johannes AT sipsolutions DOT net>
date Sun, 22 Jun 2008 00:36:25 +0200
parents c280acec2aaa
children b0d5f7f41d4b
files MoinMoin/config/multiconfig.py MoinMoin/macro/WikiConfigHelp.py
diffstat 2 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Sun Jun 22 00:21:20 2008 +0200
+++ b/MoinMoin/config/multiconfig.py	Sun Jun 22 00:36:25 2008 +0200
@@ -16,7 +16,7 @@
 logging = log.getLogger(__name__)
 
 from MoinMoin import config, error, util, wikiutil
-import MoinMoin.auth as authmodule
+from MoinMoin.auth import MoinAuth
 import MoinMoin.events as events
 from MoinMoin.events import PageChangedEvent, PageRenamedEvent
 from MoinMoin.events import PageDeletedEvent, PageCopiedEvent
@@ -622,6 +622,11 @@
         return str(err)
 
 
+class DefaultExpression(object):
+    def __init__(self, exprstr):
+        self.text = exprstr
+        self.value = eval(exprstr)
+
 options_no_group_name = {
   'various': ('Various', None, (
     ('DesktopEdition',
@@ -640,7 +645,7 @@
 
     ('allow_xslt', False, None),
     ('antispam_master_url', "http://master.moinmo.in/?action=xmlrpc2", None),
-    ('auth', [authmodule.MoinAuth()], None),
+    ('auth', DefaultExpression('[MoinAuth()]'), None),
     ('auth_methods_trusted', ['http', 'xmlrpc_applytoken'], None),
 
     ('bang_meta', True, None),
@@ -824,7 +829,7 @@
 
 
 
-    ('password_checker', _default_password_checker, None),
+    ('password_checker', DefaultExpression('_default_password_checker'), None),
 
     ('quicklinks_default', [], None),
 
@@ -1082,6 +1087,8 @@
         for name, default, doc in group_opts:
             if addgroup:
                 name = groupname + '_' + name
+            if isinstance(default, DefaultExpression):
+                default = default.value
             setattr(DefaultConfig, name, default)
 
 _add_options_to_defconfig(options)
--- a/MoinMoin/macro/WikiConfigHelp.py	Sun Jun 22 00:21:20 2008 +0200
+++ b/MoinMoin/macro/WikiConfigHelp.py	Sun Jun 22 00:36:25 2008 +0200
@@ -47,9 +47,12 @@
         for name, default, description in opts:
             if addgroup:
                 name = groupname + '_' + name
-            default_txt = '%r' % (default, )
-            if len(default_txt) > 50:
-                default_txt = '...'
+            if isinstance(default, multiconfig.DefaultExpression):
+                default_txt = default.text
+            else:
+                default_txt = '%r' % (default, )
+                if len(default_txt) > 50:
+                    default_txt = '...'
             ret.extend([
                 f.table_row(1),
                 f.table_cell(1), f.text(name), f.table_cell(0),