moinsetup

Changeset

50:8397464647da
2011-09-29 Paul Boddie raw files shortlog changelog graph Made the superuser setting optional. Introduced a utility method for getting the moin script location. Tidied up the configuration output. Added some comments.
moinsetup.py (file)
     1.1 --- a/moinsetup.py	Sun Sep 25 22:18:26 2011 +0200
     1.2 +++ b/moinsetup.py	Thu Sep 29 01:05:28 2011 +0200
     1.3 @@ -384,7 +384,7 @@
     1.4            * url_path          - the URL path at which the Wiki will be made
     1.5                                  available (such as / or /mywiki)
     1.6            * superuser         - the name of the site's superuser (such as
     1.7 -                                "AdminUser")
     1.8 +                                "AdminUser", can be omitted)
     1.9            * site_name         - the name of the site (such as "My Wiki")
    1.10            * site_identifier   - optional: an identifier used to refer to the
    1.11                                  site, typically derived from 'site_name'
    1.12 @@ -457,8 +457,12 @@
    1.13                  raise SetupException, "The static resources could not be found."
    1.14  
    1.15          # Add the static identifier to the URL path. For example:
    1.16 +        #
    1.17          # /         -> /moin_static187
    1.18          # /hgwiki   -> /hgwiki-moin_static187
    1.19 +        #
    1.20 +        # This allows multiple Wiki instances to have their own static resources
    1.21 +        # in the same hosting area.
    1.22  
    1.23          self.static_url_path = self.url_path + (self.url_path != "/" and "-" or "") + self.get_static_identifier()
    1.24  
    1.25 @@ -484,7 +488,7 @@
    1.26              print "-" * len(section)
    1.27              print
    1.28              for setting in getattr(self, "%s_config_names" % section):
    1.29 -                print "%-20s%s" % (setting, getattr(self, setting))
    1.30 +                print "%-24s%s" % (setting, getattr(self, setting))
    1.31              print
    1.32  
    1.33      def _get_abspath(self, d):
    1.34 @@ -548,6 +552,12 @@
    1.35          return self.moin_distribution and join(self.moin_distribution, "wiki") or \
    1.36              self.prefix and join(self.prefix, "share", "moin") or None
    1.37  
    1.38 +    def get_moin_script(self):
    1.39 +
    1.40 +        "Return the location of the general-purpose moin script."
    1.41 +
    1.42 +        return join(self.prefix, "bin", "moin")
    1.43 +
    1.44      def get_wikiconfig_directory(self):
    1.45  
    1.46          "Return the location of the Wiki configuration."
    1.47 @@ -719,8 +729,6 @@
    1.48              raise SetupException, \
    1.49                  "Cannot configure MoinMoin without either a 'moin_distribution' or a 'prefix' setting being defined."
    1.50  
    1.51 -        # NOTE: Single Wiki only so far.
    1.52 -
    1.53          # NOTE: MoinMoin usually uses an apparently common URL space associated
    1.54          # NOTE: with the version, but more specific locations are probably
    1.55          # NOTE: acceptable if less efficient.
    1.56 @@ -748,8 +756,11 @@
    1.57  
    1.58          try:
    1.59              wikiconfig.set("url_prefix_static", url_prefix_static, raw=1)
    1.60 -            wikiconfig.set("superuser", [self.superuser])
    1.61 -            wikiconfig.set("acl_rights_before", u"%s:read,write,delete,revert,admin" % self.superuser)
    1.62 +            if self.superuser:
    1.63 +                wikiconfig.set("superuser", [self.superuser])
    1.64 +                wikiconfig.set("acl_rights_before", u"%s:read,write,delete,revert,admin" % self.superuser)
    1.65 +            else:
    1.66 +                note("Superuser not defined. The ACL rules should be fixed in the configuration.")
    1.67  
    1.68              # Edit any created Wiki configuration.
    1.69  
    1.70 @@ -797,8 +808,7 @@
    1.71  
    1.72          "Edit the moin script."
    1.73  
    1.74 -        moin_script = join(self.prefix, "bin", "moin")
    1.75 -
    1.76 +        moin_script = self.get_moin_script()
    1.77          status("Editing moin script at %s..." % moin_script)
    1.78  
    1.79          s = readfile(moin_script)
    1.80 @@ -857,7 +867,8 @@
    1.81  
    1.82          "Add the superuser account."
    1.83  
    1.84 -        moin_script = join(self.prefix, "bin", "moin")
    1.85 +        if not self.superuser:
    1.86 +            return
    1.87  
    1.88          print "Creating superuser", self.superuser, "using..."
    1.89          email = raw_input("E-mail address: ")
    1.90 @@ -870,8 +881,8 @@
    1.91          else:
    1.92              os.environ["PYTHONPATH"] = self.common_dir
    1.93  
    1.94 -        cmd = moin_script + " --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % (
    1.95 -            self.common_dir, self.superuser, email, password)
    1.96 +        cmd = "%s --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % (
    1.97 +            self.get_moin_script(), self.common_dir, self.superuser, email, password)
    1.98          os.system(cmd)
    1.99  
   1.100          if path: