# HG changeset patch # User Paul Boddie # Date 1317251128 -7200 # Node ID 8397464647da48243a93dbe628d6070927909783 # Parent 65e9878b1625423146260e9cff1548fba0c90937 Made the superuser setting optional. Introduced a utility method for getting the moin script location. Tidied up the configuration output. Added some comments. diff -r 65e9878b1625 -r 8397464647da moinsetup.py --- a/moinsetup.py Sun Sep 25 22:18:26 2011 +0200 +++ b/moinsetup.py Thu Sep 29 01:05:28 2011 +0200 @@ -384,7 +384,7 @@ * url_path - the URL path at which the Wiki will be made available (such as / or /mywiki) * superuser - the name of the site's superuser (such as - "AdminUser") + "AdminUser", can be omitted) * site_name - the name of the site (such as "My Wiki") * site_identifier - optional: an identifier used to refer to the site, typically derived from 'site_name' @@ -457,8 +457,12 @@ raise SetupException, "The static resources could not be found." # Add the static identifier to the URL path. For example: + # # / -> /moin_static187 # /hgwiki -> /hgwiki-moin_static187 + # + # This allows multiple Wiki instances to have their own static resources + # in the same hosting area. self.static_url_path = self.url_path + (self.url_path != "/" and "-" or "") + self.get_static_identifier() @@ -484,7 +488,7 @@ print "-" * len(section) print for setting in getattr(self, "%s_config_names" % section): - print "%-20s%s" % (setting, getattr(self, setting)) + print "%-24s%s" % (setting, getattr(self, setting)) print def _get_abspath(self, d): @@ -548,6 +552,12 @@ return self.moin_distribution and join(self.moin_distribution, "wiki") or \ self.prefix and join(self.prefix, "share", "moin") or None + def get_moin_script(self): + + "Return the location of the general-purpose moin script." + + return join(self.prefix, "bin", "moin") + def get_wikiconfig_directory(self): "Return the location of the Wiki configuration." @@ -719,8 +729,6 @@ raise SetupException, \ "Cannot configure MoinMoin without either a 'moin_distribution' or a 'prefix' setting being defined." - # NOTE: Single Wiki only so far. - # NOTE: MoinMoin usually uses an apparently common URL space associated # NOTE: with the version, but more specific locations are probably # NOTE: acceptable if less efficient. @@ -748,8 +756,11 @@ try: wikiconfig.set("url_prefix_static", url_prefix_static, raw=1) - wikiconfig.set("superuser", [self.superuser]) - wikiconfig.set("acl_rights_before", u"%s:read,write,delete,revert,admin" % self.superuser) + if self.superuser: + wikiconfig.set("superuser", [self.superuser]) + wikiconfig.set("acl_rights_before", u"%s:read,write,delete,revert,admin" % self.superuser) + else: + note("Superuser not defined. The ACL rules should be fixed in the configuration.") # Edit any created Wiki configuration. @@ -797,8 +808,7 @@ "Edit the moin script." - moin_script = join(self.prefix, "bin", "moin") - + moin_script = self.get_moin_script() status("Editing moin script at %s..." % moin_script) s = readfile(moin_script) @@ -857,7 +867,8 @@ "Add the superuser account." - moin_script = join(self.prefix, "bin", "moin") + if not self.superuser: + return print "Creating superuser", self.superuser, "using..." email = raw_input("E-mail address: ") @@ -870,8 +881,8 @@ else: os.environ["PYTHONPATH"] = self.common_dir - cmd = moin_script + " --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % ( - self.common_dir, self.superuser, email, password) + cmd = "%s --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % ( + self.get_moin_script(), self.common_dir, self.superuser, email, password) os.system(cmd) if path: