Index: postman/config.py
===================================================================
--- postman/config.py	(revision 11)
+++ postman/config.py	(revision 14)
@@ -14,41 +14,92 @@
 from ConfigParser import SafeConfigParser
 
+class DaemonConfig():
+    def __init__(self, configfile=None):
+        self.configfile = configfile
+        self.default_paths = ['/usr/local/etc/postman', '/usr/local/etc',
+                              '/etc/postman', '/etc',
+                              os.path.join(os.path.dirname(__file__),'../conf')]
+        self.config = {}
+
+    @property
+    def default_filename(self):
+        """
+        Method to get the default configuration filename. It is a method instead
+        of an attribute for easier subclassing
+        """
+        return 'postman.conf'
+
+    @property
+    def sections(self):
+        """
+        Method to get the list of available sections in the configuration file.
+        It is a method instead of an attribute for easier subclassing.
+
+        FIXME: Perhaps it would be better to dinamically get the list of
+        sections from the configuration file itself.
+        """
+        return ['xmlrpc_server', 'storage', 'archive',
+                'mailing_lists', 'members']
+    
+    def validate_configfile(self):        
+        if self.configfile:
+            if not os.path.exists(self.configfile):
+                # the file does not exist, so we override it with None,
+                # allowing the next few lines to search for a valid
+                # config file on the usual places
+                self.configfile = None
+            
+        if not self.configfile:
+            for path in self.default_paths:
+                full_path = os.path.join(path, self.default_filename)
+                if os.path.exists(full_path):
+                    self.configfile = full_path
+                    return full_path
+                
+        # if we reach here, self.configfile will be still None, no valid
+        # config files were found, and so we raise an exception
+        raise IOError('ERROR - Can not find ' + self.default_filename + \
+                      ' in your environment')
+
+    def load(self):
+        if not self.configfile:
+            self.validate_configfile()
+        parser = SafeConfigParser()
+        parser.read(self.configfile)
+        for section in self.sections:
+            self.config[section] = {}
+            for name, value in parser.items(section):
+                self.config[section][name] = value
+        return self.config        
+
+    def get_section_parameters(self, section):
+        if section not in self.sections:
+            raise IndexError('ERROR - ' + section + \
+                             ' is not one of the available sections: ' + \
+                             ', '.join(self.sections))
+        if section not in self.config.keys():
+            # perhaps the config hasn't been loaded yet
+            self.load()
+
+        return self.config[section]
+
+class MTAClientConfig(DaemonConfig):
+    @property
+    def default_filename():
+        return 'postman-mta.conf'
+
+    @property
+    def sections(self):
+        return ['postman_server', ]
+
+
 def get_config_parameters(section=None, configfile=None):
-    if not configfile:
-        # If there is no config file defined, try with the usual places
-        # for config files, if there is no config file there, try to load
-        # the one provided with postman sources
-        default_paths = ['/usr/local/etc/postman/postman.conf',
-                         '/usr/local/etc/postman.conf',
-                         '/etc/postman/postman.conf',
-                         '/etc/postman.conf',
-                         os.path.join(os.path.dirname(__file__),
-                                      '../conf/postman.conf')]
-        for path in default_paths:
-            if os.path.exists(path):
-                configfile = path
-                break
-            
-    # if there is no config file now, raise an exception, as we need one
-    if not configfile:
-        raise IOError('ERROR - Can not find postman.conf in your environment')
+    """
+    This function is kept here for backwards compatibility.
+    By default all the daemon code will use this function to get
+    configuration parameters from the default configuration file.
+    """
+    config = DaemonConfig(configfile)
+    return config.get_section_parameters(section)
 
-    available_sections = ['xmlrpc_server', 'storage', 'archive',
-                          'mailing_lists', 'members']
-
-    config = {}
-
-    parser = SafeConfigParser()
-    # FIXME: we should check here if the config file has been read correctly,
-    # instead of letting an exception to pass through
-    parser.read(configfile)
-
-    if section in available_sections:
-        for name, value in parser.items(section):
-            config[name] = value
-        return config
-
-    # if no section (or an invalid section) is provided, return an empty config
-    # set
-    return config
-
+    
