moinsetup

Changeset

41:017c032959db
2011-09-13 Paul Boddie raw files shortlog changelog graph Added initial support for special farmconfig and Wiki configuration locations typically employed when Moin is installed from an operating system distribution package.
TO_DO.txt (file) moinsetup.cfg (file) moinsetup.py (file)
     1.1 --- a/TO_DO.txt	Sun Aug 28 00:54:41 2011 +0200
     1.2 +++ b/TO_DO.txt	Tue Sep 13 00:07:23 2011 +0200
     1.3 @@ -1,3 +1,5 @@
     1.4 +Support installations without the conf directory structure.
     1.5 +Add support for changing the wikis list in the farmconfig module.
     1.6  Support existing MoinMoin home directory installations into ~/lib/python2.x/MoinMoin.
     1.7    This affects the page package installation function which expects to find
     1.8    MoinMoin/packages.py inside site-packages. Running "python -m" only works with
     2.1 --- a/moinsetup.cfg	Sun Aug 28 00:54:41 2011 +0200
     2.2 +++ b/moinsetup.cfg	Tue Sep 13 00:07:23 2011 +0200
     2.3 @@ -8,6 +8,8 @@
     2.4  
     2.5  [site]
     2.6  common_dir        = wiki
     2.7 +farm_config       =
     2.8 +site_config       =
     2.9  url_path          = /
    2.10  superuser         = AdminUser
    2.11  site_name         = My Wiki
     3.1 --- a/moinsetup.py	Sun Aug 28 00:54:41 2011 +0200
     3.2 +++ b/moinsetup.py	Tue Sep 13 00:07:23 2011 +0200
     3.3 @@ -329,7 +329,8 @@
     3.4  
     3.5      def __init__(self, moin_distribution, moin_data, prefix, web_app_dir,
     3.6          common_dir, url_path, superuser, site_name, front_page_name,
     3.7 -        web_site_dir=None, web_static_dir=None, theme_default=None):
     3.8 +        web_site_dir=None, web_static_dir=None, farm_config=None,
     3.9 +        site_config=None, theme_default=None):
    3.10  
    3.11          """
    3.12          Initialise a Wiki installation using the following:
    3.13 @@ -356,6 +357,11 @@
    3.14                                  /etc/apache2/sites-available)
    3.15            * web_static_dir    - optional: the directory where static Web
    3.16                                  resources reside (such as /home/www-user/htdocs)
    3.17 +          * farm_config       - optional: any Wiki farm configuration file for
    3.18 +                                multiple Wiki deployments (overrides the
    3.19 +                                'common_dir' setting)
    3.20 +          * site_config       - optional: a specific configuration file location
    3.21 +                                (overrides the 'common_dir' setting)
    3.22            * theme_default     - optional: the default theme (such as modern)
    3.23          """
    3.24  
    3.25 @@ -364,6 +370,8 @@
    3.26          self.superuser = superuser
    3.27          self.site_name = site_name
    3.28          self.front_page_name = front_page_name
    3.29 +        self.farm_config = farm_config
    3.30 +        self.site_config = site_config
    3.31          self.theme_default = theme_default
    3.32  
    3.33          # NOTE: Support the detection of the Apache sites directory.
    3.34 @@ -658,10 +666,16 @@
    3.35          else:
    3.36              url_prefix_static = "%r" % self.static_url_path
    3.37  
    3.38 -        # Copy the Wiki configuration file from the distribution.
    3.39 +        # Use a farm configuration file.
    3.40 +
    3.41 +        if self.farm_config:
    3.42 +            wikiconfig_py = self.farm_config
    3.43  
    3.44 -        wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
    3.45 -        shutil.copyfile(join(moin_data, "config", "wikiconfig.py"), wikiconfig_py)
    3.46 +        # Or copy the Wiki configuration file from the distribution.
    3.47 +
    3.48 +        else:
    3.49 +            wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
    3.50 +            shutil.copyfile(join(moin_data, "config", "wikiconfig.py"), wikiconfig_py)
    3.51  
    3.52          status("Editing configuration from %s..." % wikiconfig_py)
    3.53  
    3.54 @@ -674,24 +688,39 @@
    3.55              wikiconfig.set("superuser", [self.superuser])
    3.56              wikiconfig.set("acl_rights_before", u"%s:read,write,delete,revert,admin" % self.superuser)
    3.57  
    3.58 -            if not self.moin_version.startswith("1.9"):
    3.59 -                data_dir = join(self.conf_dir, "data")
    3.60 -                data_underlay_dir = join(self.conf_dir, "underlay")
    3.61 +            # Edit any created Wiki configuration.
    3.62  
    3.63 -                wikiconfig.set("data_dir", data_dir)
    3.64 -                wikiconfig.set("data_underlay_dir", data_underlay_dir)
    3.65 -
    3.66 -            self._configure_moin(wikiconfig)
    3.67 +            if not self.site_config:
    3.68 +                self._configure_moin(wikiconfig)
    3.69  
    3.70          finally:
    3.71              wikiconfig.close()
    3.72  
    3.73 +        # Edit any separate site configuration file.
    3.74 +
    3.75 +        if self.site_config:
    3.76 +            status("Editing configuration from %s..." % self.site_config)
    3.77 +
    3.78 +            wikiconfig = Configuration(self.site_config)
    3.79 +
    3.80 +            try:
    3.81 +                self._configure_moin(wikiconfig)
    3.82 +            finally:
    3.83 +                wikiconfig.close()
    3.84 +
    3.85      def _configure_moin(self, wikiconfig):
    3.86  
    3.87          """
    3.88          Configure Moin, accessing the configuration file using 'wikiconfig'.
    3.89          """
    3.90  
    3.91 +        if not self.moin_version.startswith("1.9"):
    3.92 +            data_dir = join(self.conf_dir, "data")
    3.93 +            data_underlay_dir = join(self.conf_dir, "underlay")
    3.94 +
    3.95 +            wikiconfig.set("data_dir", data_dir)
    3.96 +            wikiconfig.set("data_underlay_dir", data_underlay_dir)
    3.97 +
    3.98          wikiconfig.set("site_name", self.site_name)
    3.99          wikiconfig.set("page_front_page", self.front_page_name, count=1)
   3.100  
   3.101 @@ -771,7 +800,9 @@
   3.102          else:
   3.103              os.environ["PYTHONPATH"] = self.conf_dir
   3.104  
   3.105 -        os.system(moin_script + " account create --name='%s' --email='%s' --password='%s'" % (self.superuser, email, password))
   3.106 +        cmd = moin_script + " --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % (
   3.107 +            self.conf_dir, self.superuser, email, password)
   3.108 +        os.system(cmd)
   3.109  
   3.110          if path:
   3.111              os.environ["PYTHONPATH"] = path
   3.112 @@ -874,9 +905,15 @@
   3.113  
   3.114          If 'name' and the remaining parameters are omitted, the default
   3.115          configuration activity is performed.
   3.116 +
   3.117 +        If the 'site_config' setting is defined, the specific site configuration
   3.118 +        will be changed.
   3.119          """
   3.120  
   3.121 -        wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
   3.122 +        if self.site_config:
   3.123 +            wikiconfig_py = self.site_config
   3.124 +        else:
   3.125 +            wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
   3.126  
   3.127          status("Editing configuration from %s..." % wikiconfig_py)
   3.128  
   3.129 @@ -898,9 +935,15 @@
   3.130          """
   3.131          Edit the installed Wiki configuration file, configuring the
   3.132          authentication method having the given 'method_name'.
   3.133 +
   3.134 +        If the 'farm_config' setting is defined, the Wiki farm configuration
   3.135 +        will be changed.
   3.136          """
   3.137  
   3.138 -        wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
   3.139 +        if self.farm_config:
   3.140 +            wikiconfig_py = self.farm_config
   3.141 +        else:
   3.142 +            wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
   3.143  
   3.144          status("Editing configuration from %s..." % wikiconfig_py)
   3.145