Rev 35: Rework constructors and create a new base class for web servers. in http://bazaar.launchpad.net/%7Evila/bzr/local-test-server

Vincent Ladeuil v.ladeuil+lp at free.fr
Sun Jun 22 17:48:33 BST 2008


At http://bazaar.launchpad.net/%7Evila/bzr/local-test-server

------------------------------------------------------------
revno: 35
revision-id: v.ladeuil+lp at free.fr-20080622164831-hdlm86vmu8hszqvj
parent: v.ladeuil+lp at free.fr-20080615085923-rebxna19i92rwyim
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: local_test_server
timestamp: Sun 2008-06-22 18:48:31 +0200
message:
  Rework constructors and create a new base class for web servers.
  
  * config.py:
  (Config.__init__): Remove http specifics.
  (HttpConfig): New base class for web servers.
  (Apache2.__init__): Change prototype so that daughter classes can
  reuse it.
  (Apache2DAV.__init__, Apache2SVN.__init__, Cherokee.__init__,
  Lighttpd.__init__, LighttpdDAV.__init__): Address FIXME.
modified:
  config.py                      __init__.py-20080523170713-0c8mnxio9r41iyhk-1
-------------- next part --------------
=== modified file 'config.py'
--- a/config.py	2008-06-13 15:10:45 +0000
+++ b/config.py	2008-06-22 16:48:31 +0000
@@ -60,8 +60,7 @@
         # We need at least a place to put the generated configuration file and
         # the pidfile.
         self.required_dirs = dict(etc_dir='etc', var_run_dir='var/run',
-                                  var_log_dir='var/log',
-                                  www_dir='www')
+                                  var_log_dir='var/log')
         if required_dirs is not None:
             self.required_dirs.update(required_dirs)
 
@@ -100,54 +99,60 @@
         return self.values.get(name, default)
 
 
-class Apache2(Config):
+class HttpConfig(Config):
+
+    def __init__(self, name, required_dirs=None, _base_dir=None):
+        if required_dirs is None:
+            required_dirs = {}
+        required_dirs['www_dir'] = 'www'
+        super(HttpConfig, self).__init__(name, required_dirs, _base_dir)
+
+
+class Apache2(HttpConfig):
 
     _required_dirs = dict(var_lock_dir='var/lock')
 
-    def __init__(self, _base_dir=None):
-        super(Apache2, self).__init__('apache2',
-                                      required_dirs=self._required_dirs,
-                                      _base_dir=_base_dir)
+    def __init__(self, name=None, required_dirs=None, _base_dir=None):
+        if name is None:
+            name = 'apache2'
+        super(Apache2, self).__init__(
+            name, required_dirs=self._required_dirs, _base_dir=_base_dir)
 
 
 class Apache2DAV(Apache2):
 
     def __init__(self, _base_dir=None):
-        # FIXME: jumping over Apache2 >-/
-        Config.__init__(self, 'apache2-dav',
-                        required_dirs=self._required_dirs,
-                        _base_dir=_base_dir)
+        super(Apache2DAV, self).__init__(
+            'apache2-dav',
+            required_dirs=self._required_dirs, _base_dir=_base_dir,)
 
 
 class Apache2SVN(Apache2):
 
     def __init__(self, _base_dir=None):
-        # FIXME: jumping over Apache2 >-/
-        Config.__init__(self, 'apache2-svn',
-                        required_dirs=self._required_dirs,
-                        _base_dir=_base_dir)
+        super(Apache2SVN, self).__init__(
+            'apache2-svn',
+            required_dirs=self._required_dirs, _base_dir=_base_dir)
         self.values['svn_dir'] = self.abspath('svn')
 
 
-class Cherokee(Config):
-
-    def __init__(self, _base_dir=None):
-        super(Cherokee, self).__init__('cherokee',
-                                      _base_dir=_base_dir)
-
-
-class Lighttpd(Config):
-
-    def __init__(self, _base_dir=None):
-        super(Lighttpd, self).__init__('lighttpd',
-                                      _base_dir=_base_dir)
+class Cherokee(HttpConfig):
+
+    def __init__(self, _base_dir=None):
+        super(Cherokee, self).__init__('cherokee', _base_dir=_base_dir)
+
+
+class Lighttpd(HttpConfig):
+
+    def __init__(self, name=None, _base_dir=None):
+        if name is None:
+            name = 'lighttpd'
+        super(Lighttpd, self).__init__(name, _base_dir=_base_dir)
 
 
 class LighttpdDAV(Lighttpd):
 
     def __init__(self, _base_dir=None):
-        # FIXME: jumping over Lighttpd >-/
-        Config.__init__(self, 'lighttpd-dav',
-                        _base_dir=_base_dir)
+        super(LighttpdDAV, self).__init__('lighttpd-dav', _base_dir=_base_dir)
 
 



More information about the bazaar-commits mailing list