# HG changeset patch # User Paul Boddie # Date 1315865243 -7200 # Node ID 017c032959db2d6fea67c9aec6672063bfb44b4a # Parent 9a95862669f6190a9c2ab8f73ea7b167a2416b8f Added initial support for special farmconfig and Wiki configuration locations typically employed when Moin is installed from an operating system distribution package. diff -r 9a95862669f6 -r 017c032959db TO_DO.txt --- a/TO_DO.txt Sun Aug 28 00:54:41 2011 +0200 +++ b/TO_DO.txt Tue Sep 13 00:07:23 2011 +0200 @@ -1,3 +1,5 @@ +Support installations without the conf directory structure. +Add support for changing the wikis list in the farmconfig module. Support existing MoinMoin home directory installations into ~/lib/python2.x/MoinMoin. This affects the page package installation function which expects to find MoinMoin/packages.py inside site-packages. Running "python -m" only works with diff -r 9a95862669f6 -r 017c032959db moinsetup.cfg --- a/moinsetup.cfg Sun Aug 28 00:54:41 2011 +0200 +++ b/moinsetup.cfg Tue Sep 13 00:07:23 2011 +0200 @@ -8,6 +8,8 @@ [site] common_dir = wiki +farm_config = +site_config = url_path = / superuser = AdminUser site_name = My Wiki diff -r 9a95862669f6 -r 017c032959db moinsetup.py --- a/moinsetup.py Sun Aug 28 00:54:41 2011 +0200 +++ b/moinsetup.py Tue Sep 13 00:07:23 2011 +0200 @@ -329,7 +329,8 @@ def __init__(self, moin_distribution, moin_data, prefix, web_app_dir, common_dir, url_path, superuser, site_name, front_page_name, - web_site_dir=None, web_static_dir=None, theme_default=None): + web_site_dir=None, web_static_dir=None, farm_config=None, + site_config=None, theme_default=None): """ Initialise a Wiki installation using the following: @@ -356,6 +357,11 @@ /etc/apache2/sites-available) * web_static_dir - optional: the directory where static Web resources reside (such as /home/www-user/htdocs) + * farm_config - optional: any Wiki farm configuration file for + multiple Wiki deployments (overrides the + 'common_dir' setting) + * site_config - optional: a specific configuration file location + (overrides the 'common_dir' setting) * theme_default - optional: the default theme (such as modern) """ @@ -364,6 +370,8 @@ self.superuser = superuser self.site_name = site_name self.front_page_name = front_page_name + self.farm_config = farm_config + self.site_config = site_config self.theme_default = theme_default # NOTE: Support the detection of the Apache sites directory. @@ -658,10 +666,16 @@ else: url_prefix_static = "%r" % self.static_url_path - # Copy the Wiki configuration file from the distribution. + # Use a farm configuration file. + + if self.farm_config: + wikiconfig_py = self.farm_config - wikiconfig_py = join(self.conf_dir, "wikiconfig.py") - shutil.copyfile(join(moin_data, "config", "wikiconfig.py"), wikiconfig_py) + # Or copy the Wiki configuration file from the distribution. + + else: + wikiconfig_py = join(self.conf_dir, "wikiconfig.py") + shutil.copyfile(join(moin_data, "config", "wikiconfig.py"), wikiconfig_py) status("Editing configuration from %s..." % wikiconfig_py) @@ -674,24 +688,39 @@ wikiconfig.set("superuser", [self.superuser]) wikiconfig.set("acl_rights_before", u"%s:read,write,delete,revert,admin" % self.superuser) - if not self.moin_version.startswith("1.9"): - data_dir = join(self.conf_dir, "data") - data_underlay_dir = join(self.conf_dir, "underlay") + # Edit any created Wiki configuration. - wikiconfig.set("data_dir", data_dir) - wikiconfig.set("data_underlay_dir", data_underlay_dir) - - self._configure_moin(wikiconfig) + if not self.site_config: + self._configure_moin(wikiconfig) finally: wikiconfig.close() + # Edit any separate site configuration file. + + if self.site_config: + status("Editing configuration from %s..." % self.site_config) + + wikiconfig = Configuration(self.site_config) + + try: + self._configure_moin(wikiconfig) + finally: + wikiconfig.close() + def _configure_moin(self, wikiconfig): """ Configure Moin, accessing the configuration file using 'wikiconfig'. """ + if not self.moin_version.startswith("1.9"): + data_dir = join(self.conf_dir, "data") + data_underlay_dir = join(self.conf_dir, "underlay") + + wikiconfig.set("data_dir", data_dir) + wikiconfig.set("data_underlay_dir", data_underlay_dir) + wikiconfig.set("site_name", self.site_name) wikiconfig.set("page_front_page", self.front_page_name, count=1) @@ -771,7 +800,9 @@ else: os.environ["PYTHONPATH"] = self.conf_dir - os.system(moin_script + " account create --name='%s' --email='%s' --password='%s'" % (self.superuser, email, password)) + cmd = moin_script + " --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % ( + self.conf_dir, self.superuser, email, password) + os.system(cmd) if path: os.environ["PYTHONPATH"] = path @@ -874,9 +905,15 @@ If 'name' and the remaining parameters are omitted, the default configuration activity is performed. + + If the 'site_config' setting is defined, the specific site configuration + will be changed. """ - wikiconfig_py = join(self.conf_dir, "wikiconfig.py") + if self.site_config: + wikiconfig_py = self.site_config + else: + wikiconfig_py = join(self.conf_dir, "wikiconfig.py") status("Editing configuration from %s..." % wikiconfig_py) @@ -898,9 +935,15 @@ """ Edit the installed Wiki configuration file, configuring the authentication method having the given 'method_name'. + + If the 'farm_config' setting is defined, the Wiki farm configuration + will be changed. """ - wikiconfig_py = join(self.conf_dir, "wikiconfig.py") + if self.farm_config: + wikiconfig_py = self.farm_config + else: + wikiconfig_py = join(self.conf_dir, "wikiconfig.py") status("Editing configuration from %s..." % wikiconfig_py)