1.1 --- a/moinsetup.py Sun Aug 28 00:54:41 2011 +0200
1.2 +++ b/moinsetup.py Tue Sep 13 00:07:23 2011 +0200
1.3 @@ -329,7 +329,8 @@
1.4
1.5 def __init__(self, moin_distribution, moin_data, prefix, web_app_dir,
1.6 common_dir, url_path, superuser, site_name, front_page_name,
1.7 - web_site_dir=None, web_static_dir=None, theme_default=None):
1.8 + web_site_dir=None, web_static_dir=None, farm_config=None,
1.9 + site_config=None, theme_default=None):
1.10
1.11 """
1.12 Initialise a Wiki installation using the following:
1.13 @@ -356,6 +357,11 @@
1.14 /etc/apache2/sites-available)
1.15 * web_static_dir - optional: the directory where static Web
1.16 resources reside (such as /home/www-user/htdocs)
1.17 + * farm_config - optional: any Wiki farm configuration file for
1.18 + multiple Wiki deployments (overrides the
1.19 + 'common_dir' setting)
1.20 + * site_config - optional: a specific configuration file location
1.21 + (overrides the 'common_dir' setting)
1.22 * theme_default - optional: the default theme (such as modern)
1.23 """
1.24
1.25 @@ -364,6 +370,8 @@
1.26 self.superuser = superuser
1.27 self.site_name = site_name
1.28 self.front_page_name = front_page_name
1.29 + self.farm_config = farm_config
1.30 + self.site_config = site_config
1.31 self.theme_default = theme_default
1.32
1.33 # NOTE: Support the detection of the Apache sites directory.
1.34 @@ -658,10 +666,16 @@
1.35 else:
1.36 url_prefix_static = "%r" % self.static_url_path
1.37
1.38 - # Copy the Wiki configuration file from the distribution.
1.39 + # Use a farm configuration file.
1.40 +
1.41 + if self.farm_config:
1.42 + wikiconfig_py = self.farm_config
1.43
1.44 - wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
1.45 - shutil.copyfile(join(moin_data, "config", "wikiconfig.py"), wikiconfig_py)
1.46 + # Or copy the Wiki configuration file from the distribution.
1.47 +
1.48 + else:
1.49 + wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
1.50 + shutil.copyfile(join(moin_data, "config", "wikiconfig.py"), wikiconfig_py)
1.51
1.52 status("Editing configuration from %s..." % wikiconfig_py)
1.53
1.54 @@ -674,24 +688,39 @@
1.55 wikiconfig.set("superuser", [self.superuser])
1.56 wikiconfig.set("acl_rights_before", u"%s:read,write,delete,revert,admin" % self.superuser)
1.57
1.58 - if not self.moin_version.startswith("1.9"):
1.59 - data_dir = join(self.conf_dir, "data")
1.60 - data_underlay_dir = join(self.conf_dir, "underlay")
1.61 + # Edit any created Wiki configuration.
1.62
1.63 - wikiconfig.set("data_dir", data_dir)
1.64 - wikiconfig.set("data_underlay_dir", data_underlay_dir)
1.65 -
1.66 - self._configure_moin(wikiconfig)
1.67 + if not self.site_config:
1.68 + self._configure_moin(wikiconfig)
1.69
1.70 finally:
1.71 wikiconfig.close()
1.72
1.73 + # Edit any separate site configuration file.
1.74 +
1.75 + if self.site_config:
1.76 + status("Editing configuration from %s..." % self.site_config)
1.77 +
1.78 + wikiconfig = Configuration(self.site_config)
1.79 +
1.80 + try:
1.81 + self._configure_moin(wikiconfig)
1.82 + finally:
1.83 + wikiconfig.close()
1.84 +
1.85 def _configure_moin(self, wikiconfig):
1.86
1.87 """
1.88 Configure Moin, accessing the configuration file using 'wikiconfig'.
1.89 """
1.90
1.91 + if not self.moin_version.startswith("1.9"):
1.92 + data_dir = join(self.conf_dir, "data")
1.93 + data_underlay_dir = join(self.conf_dir, "underlay")
1.94 +
1.95 + wikiconfig.set("data_dir", data_dir)
1.96 + wikiconfig.set("data_underlay_dir", data_underlay_dir)
1.97 +
1.98 wikiconfig.set("site_name", self.site_name)
1.99 wikiconfig.set("page_front_page", self.front_page_name, count=1)
1.100
1.101 @@ -771,7 +800,9 @@
1.102 else:
1.103 os.environ["PYTHONPATH"] = self.conf_dir
1.104
1.105 - os.system(moin_script + " account create --name='%s' --email='%s' --password='%s'" % (self.superuser, email, password))
1.106 + cmd = moin_script + " --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % (
1.107 + self.conf_dir, self.superuser, email, password)
1.108 + os.system(cmd)
1.109
1.110 if path:
1.111 os.environ["PYTHONPATH"] = path
1.112 @@ -874,9 +905,15 @@
1.113
1.114 If 'name' and the remaining parameters are omitted, the default
1.115 configuration activity is performed.
1.116 +
1.117 + If the 'site_config' setting is defined, the specific site configuration
1.118 + will be changed.
1.119 """
1.120
1.121 - wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
1.122 + if self.site_config:
1.123 + wikiconfig_py = self.site_config
1.124 + else:
1.125 + wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
1.126
1.127 status("Editing configuration from %s..." % wikiconfig_py)
1.128
1.129 @@ -898,9 +935,15 @@
1.130 """
1.131 Edit the installed Wiki configuration file, configuring the
1.132 authentication method having the given 'method_name'.
1.133 +
1.134 + If the 'farm_config' setting is defined, the Wiki farm configuration
1.135 + will be changed.
1.136 """
1.137
1.138 - wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
1.139 + if self.farm_config:
1.140 + wikiconfig_py = self.farm_config
1.141 + else:
1.142 + wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
1.143
1.144 status("Editing configuration from %s..." % wikiconfig_py)
1.145