diff MoinMoin/config/multiconfig.py @ 3881:15bd8dae9003

merged some 1.7 changesets
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 27 Jul 2008 13:21:17 +0200
parents e5a9570d3001 85cd05b8af42
children f85cd27073a9
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Sun Jul 27 12:59:45 2008 +0200
+++ b/MoinMoin/config/multiconfig.py	Sun Jul 27 13:21:17 2008 +0200
@@ -362,6 +362,9 @@
         if self.url_prefix_local is None:
             self.url_prefix_local = self.url_prefix_static
 
+        if self.secrets is None:  # admin did not setup a real secret, so make up something
+            self.secrets = self.calc_secrets()
+
         secret_key_names = ['action/cache', 'wikiutil/tickets', 'xmlrpc/ProcessMail', 'xmlrpc/RemoteScript', ]
         if self.jabber_enabled:
             secret_key_names.append('jabberbot')
@@ -387,6 +390,19 @@
                 raise error.ConfigurationError("You must set a (at least %d chars long) secret string for secrets['%s']!" % (
                     secret_min_length, secret_key_name))
 
+    def calc_secrets(self):
+        """ make up some 'secret' using some config values """
+        varnames = ['data_dir', 'data_underlay_dir', 'language_default',
+                    'mail_smarthost', 'mail_from', 'page_front_page',
+                    'theme_default', 'sitename', 'logo_string',
+                    'interwikiname', 'user_homewiki', 'acl_rights_before', ]
+        secret = ''
+        for varname in varnames:
+            var = getattr(self, varname, None)
+            if isinstance(var, (str, unicode)):
+                secret += repr(var)
+        return secret
+
     _meta_dict = None
     def load_meta_dict(self):
         """ The meta_dict contains meta data about the wiki instance. """
@@ -694,7 +710,7 @@
      "list of auth objects, to be called in this order (see HelpOnAuthentication)"),
     ('auth_methods_trusted', ['http', 'xmlrpc_applytoken'],
      'authentication methods for which users should be included in the special "Trusted" ACL group.'),
-    ('secrets', '', 'Either a long shared secret string used for multiple purposes or a dict {"purpose": "longsecretstring", ...} for setting up different shared secrets for different purposes. REQUIRED!'),
+    ('secrets', None, """Either a long shared secret string used for multiple purposes or a dict {"purpose": "longsecretstring", ...} for setting up different shared secrets for different purposes. If you don't setup own secret(s), a secret string will be auto-generated from other config settings."""),
     ('DesktopEdition',
      False,
      "if True, give all local users special powers - ''only use this for a local desktop wiki!''"),