comparison MoinMoin/config/multiconfig.py @ 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
comparison
equal deleted inserted replaced
3747:c280acec2aaa 3748:dc917a577d38
14 14
15 from MoinMoin import log 15 from MoinMoin import log
16 logging = log.getLogger(__name__) 16 logging = log.getLogger(__name__)
17 17
18 from MoinMoin import config, error, util, wikiutil 18 from MoinMoin import config, error, util, wikiutil
19 import MoinMoin.auth as authmodule 19 from MoinMoin.auth import MoinAuth
20 import MoinMoin.events as events 20 import MoinMoin.events as events
21 from MoinMoin.events import PageChangedEvent, PageRenamedEvent 21 from MoinMoin.events import PageChangedEvent, PageRenamedEvent
22 from MoinMoin.events import PageDeletedEvent, PageCopiedEvent 22 from MoinMoin.events import PageDeletedEvent, PageCopiedEvent
23 from MoinMoin.events import PageRevertedEvent, FileAttachedEvent 23 from MoinMoin.events import PageRevertedEvent, FileAttachedEvent
24 from MoinMoin import session 24 from MoinMoin import session
620 return None 620 return None
621 except ValueError, err: 621 except ValueError, err:
622 return str(err) 622 return str(err)
623 623
624 624
625 class DefaultExpression(object):
626 def __init__(self, exprstr):
627 self.text = exprstr
628 self.value = eval(exprstr)
629
625 options_no_group_name = { 630 options_no_group_name = {
626 'various': ('Various', None, ( 631 'various': ('Various', None, (
627 ('DesktopEdition', 632 ('DesktopEdition',
628 False, 633 False,
629 'True gives all local users special powers - ONLY use for MMDE style usage!'), 634 'True gives all local users special powers - ONLY use for MMDE style usage!'),
638 ], 643 ],
639 None), 644 None),
640 645
641 ('allow_xslt', False, None), 646 ('allow_xslt', False, None),
642 ('antispam_master_url', "http://master.moinmo.in/?action=xmlrpc2", None), 647 ('antispam_master_url', "http://master.moinmo.in/?action=xmlrpc2", None),
643 ('auth', [authmodule.MoinAuth()], None), 648 ('auth', DefaultExpression('[MoinAuth()]'), None),
644 ('auth_methods_trusted', ['http', 'xmlrpc_applytoken'], None), 649 ('auth_methods_trusted', ['http', 'xmlrpc_applytoken'], None),
645 650
646 ('bang_meta', True, None), 651 ('bang_meta', True, None),
647 ('caching_formats', ['text_html'], None), 652 ('caching_formats', ['text_html'], None),
648 ('changed_time_fmt', '%H:%M', None), 653 ('changed_time_fmt', '%H:%M', None),
822 'up': ('page_parent_page', {}, _("Up"), "up"), 827 'up': ('page_parent_page', {}, _("Up"), "up"),
823 }, None), 828 }, None),
824 829
825 830
826 831
827 ('password_checker', _default_password_checker, None), 832 ('password_checker', DefaultExpression('_default_password_checker'), None),
828 833
829 ('quicklinks_default', [], None), 834 ('quicklinks_default', [], None),
830 835
831 ('refresh', None, None), 836 ('refresh', None, None),
832 ('rss_cache', 60, None), 837 ('rss_cache', 60, None),
1080 for groupname in opts: 1085 for groupname in opts:
1081 group_short, group_doc, group_opts = opts[groupname] 1086 group_short, group_doc, group_opts = opts[groupname]
1082 for name, default, doc in group_opts: 1087 for name, default, doc in group_opts:
1083 if addgroup: 1088 if addgroup:
1084 name = groupname + '_' + name 1089 name = groupname + '_' + name
1090 if isinstance(default, DefaultExpression):
1091 default = default.value
1085 setattr(DefaultConfig, name, default) 1092 setattr(DefaultConfig, name, default)
1086 1093
1087 _add_options_to_defconfig(options) 1094 _add_options_to_defconfig(options)
1088 _add_options_to_defconfig(options_no_group_name, False) 1095 _add_options_to_defconfig(options_no_group_name, False)
1089 1096