Changeset 20:bf238ca0c37f in mailjam for mailjam/daemon.py


Ignore:
Timestamp:
May 22, 2012, 1:28:15 PM (12 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.