Changeset 16:cd4170142d87 in mailjam for mailjam/daemon.py


Ignore:
Timestamp:
May 22, 2012, 9:31:15 AM (12 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Renamed the project to Mailjam

File:
1 moved

Legend:

Unmodified
Added
Removed
  • mailjam/daemon.py

    r15 r16  
    44from SimpleXMLRPCServer import SimpleXMLRPCServer, list_public_methods
    55
    6 from postman import config
    7 from postman.models import Member, MailingList
    8 from postman.storage import JsonStorage as Storage
    9 
    10 
    11 class Postman():
     6from mailjam import config
     7from mailjam.models import Member, MailingList
     8from mailjam.storage import JsonStorage as Storage
     9
     10
     11class Mailjam():
    1212
    1313    def __init__(self, configfile=None):
     
    3333        if self.mailings:
    3434            # Save the config file from where we can reload information about
    35             # the mailing lists managed by this postman instance
     35            # the mailing lists managed by this mailjam instance
    3636            self.dbs['mailings'].write(self.mailings_addresses)
    3737            # Save each mailing list data into its separated persistence file
     
    6464        Delete all stored data from disk (useful for testing).
    6565        DANGER: Calling this method will remove all data from disk, leaving the
    66         postman instance with no persistence data, if the postman process die,
     66        mailjam instance with no persistence data, if the mailjam process die,
    6767        before another .save() call is made, all data will be lost.
    6868        """
     
    7676    def add_mailing_list(self, info={}):
    7777        """
    78         Add a new mailing list to this postman instance. expects one parameter,
     78        Add a new mailing list to this mailjam instance. expects one parameter,
    7979        info, which is a dictionary that should contain, at least, the
    8080        following keys:
     
    9696        if info['address'] in self.mailings_addresses:
    9797            raise IndexError(info['address'],
    98                              ' has been already added to postman')
     98                             ' has been already added to mailjam')
    9999
    100100        mailing = MailingList(info['name'], info['address'],
     
    109109        """
    110110        Add a new member for the mailing list represented by list_addr (a string
    111         containing the email address of any mailing list managed by this postman
     111        containing the email address of any mailing list managed by this mailjam
    112112        instance). member_addr is a string representing the email address of the
    113113        new member
     
    130130
    131131
    132 class PostmanXMLRPC():
     132class MailjamXMLRPC():
    133133    """
    134134    This class is a wrapper we will use to limit the methods that will be
     
    159159class MailingListXMLRPC():
    160160    def __init__(self):
    161         self.postman = Postman()
    162         self.postman.load()
     161        self.mailjam = Mailjam()
     162        self.mailjam.load()
    163163    def add(self, info={}):
    164         self.postman.add_mailing_list(info)
     164        self.mailjam.add_mailing_list(info)
    165165    def addresses(self):
    166         return self.postman.mailings_addresses   
     166        return self.mailjam.mailings_addresses   
    167167
    168168
    169169class MemberXMLRPC():
    170170    def __init__(self):
    171         self.postman = Postman()
    172         self.postman.load()
     171        self.mailjam = Mailjam()
     172        self.mailjam.load()
    173173    def add(self, member_addr=None, list_addr=None):
    174         self.postman.add_mailing_member(member_addr, list_addr)
     174        self.mailjam.add_mailing_member(member_addr, list_addr)
    175175    def list(self, mailing):
    176         if mailing in self.postman.mailings_addresses:
    177             return self.postman.mailings[mailing].members_addresses()
    178 
    179 
    180 class PostmanDaemon():
     176        if mailing in self.mailjam.mailings_addresses:
     177            return self.mailjam.mailings[mailing].members_addresses()
     178
     179
     180class MailjamDaemon():
    181181    def __init__(self, configfile=None):
    182182        self.config = config.get_config_parameters('xmlrpc_server', configfile)
     
    211211        """
    212212        Check if there is an initialized server (initialize it if there is none)
    213         and then register all the Postman public methods to be served through
     213        and then register all the Mailjam public methods to be served through
    214214        the xml-rpc link
    215215
     
    221221        msg = 'Registering public methods'
    222222        logging.info(msg)
    223         root = PostmanXMLRPC()
     223        root = MailjamXMLRPC()
    224224        root.lists = MailingListXMLRPC()
    225225        root.members = MemberXMLRPC()
Note: See TracChangeset for help on using the changeset viewer.