Changeset 20:bf238ca0c37f in mailjam


Ignore:
Timestamp:
May 22, 2012, 1:28:15 PM (13 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Fixed multiple bugs found while doing manual tests of both the server and
MTA client. All of those bugs are related to how configuration files are
loaded.

Location:
mailjam
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • mailjam/config.py

    r16 r20  
    4242                'mailing_lists', 'members']
    4343   
    44     def validate_configfile(self):       
     44    def validate_configfile(self):
    4545        if self.configfile:
     46            # ensure we have the full path to the provided file
     47            self.configfile = os.path.join(os.path.dirname(__file__),
     48                                           self.configfile)
    4649            if not os.path.exists(self.configfile):
    4750                # the file does not exist, so we override it with None,
     
    4952                # config file on the usual places
    5053                self.configfile = None
     54            else:
     55                return self.configfile
    5156           
    5257        if not self.configfile:
     
    5661                    self.configfile = full_path
    5762                    return full_path
    58                
     63
    5964        # if we reach here, self.configfile will be still None, no valid
    6065        # config files were found, and so we raise an exception
  • mailjam/daemon.py

    r16 r20  
    11# -*- coding: utf-8 -*-
     2
     3"""
     4The mailjam project - daemon.py
     5
     6This file is released under the BSD license, see LICENSE for
     7more information.
     8
     9Francisco de Borja Lopez Rio - <borja@codigo23.net>
     10Soluciones Informaticas Codigo23 S.L.U. - http://codigo23.net
     11"""
    212
    313import os, inspect, logging
     
    1222
    1323    def __init__(self, configfile=None):
     24        self.configfile=configfile
    1425        self.storage_config = config.get_config_parameters('storage',
    1526                                                           configfile)
     
    5465            # now load all the mailing objects:
    5566            for address in self.mailings_addresses:
    56                 mailing = MailingList(address, address)
     67                mailing = MailingList(name=address, address=address,
     68                                      configfile=self.configfile)
    5769                mailing.load()
    5870                self.mailings[address] = mailing               
     
    146158    """
    147159
     160    def __init__(self, configfile=None):
     161        self.configfile = configfile
     162
    148163    def _listMethods(self):
    149164        public_methods = []
     
    158173
    159174class MailingListXMLRPC():
    160     def __init__(self):
    161         self.mailjam = Mailjam()
     175    def __init__(self, configfile=None):
     176        self.mailjam = Mailjam(configfile=configfile)
    162177        self.mailjam.load()
    163178    def add(self, info={}):
     
    168183
    169184class MemberXMLRPC():
    170     def __init__(self):
    171         self.mailjam = Mailjam()
     185    def __init__(self, configfile=None):
     186        self.mailjam = Mailjam(configfile=configfile)
    172187        self.mailjam.load()
    173188    def add(self, member_addr=None, list_addr=None):
     
    180195class MailjamDaemon():
    181196    def __init__(self, configfile=None):
     197        self.configfile = configfile
    182198        self.config = config.get_config_parameters('xmlrpc_server', configfile)
    183 
    184         # FIXME: These should be loaded from a config file
    185199        self.address = self.config.get('address', 'localhost')
    186200        self.port = int(self.config.get('port', 9876))
     
    221235        msg = 'Registering public methods'
    222236        logging.info(msg)
    223         root = MailjamXMLRPC()
    224         root.lists = MailingListXMLRPC()
    225         root.members = MemberXMLRPC()
     237        root = MailjamXMLRPC(self.configfile)
     238        root.lists = MailingListXMLRPC(self.configfile)
     239        root.members = MemberXMLRPC(self.configfile)
    226240        self.server.register_instance(root, allow_dotted_names=True)
    227241        self.ready_to_serve = True
  • mailjam/mta.py

    r16 r20  
    2323            raise ValueError(address, ' is not a valid email address')
    2424
    25         mta_config = MTAClientConfig()
     25        mta_config = MTAClientConfig(configfile=configfile)
    2626        mta_config.load()
    2727        self.config = mta_config.config
Note: See TracChangeset for help on using the changeset viewer.