Changeset 23:adc5b22efd7e in mailjam for mailjam/daemon.py


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

Added the first version of the CLI client, which implements a shell-like
interface where users can interact with a mailjam server.

This first versions adds no "big" features, but contains the basis to build
a complete shell interface (including history saving support, completion,
help for commands, etc)

Added a custom configuration file (conf/mailjam-cli.conf) for the CLI
client.

Added a new mailjam.config class (CLIClientConfig) that is used by the CLI
client to load its configuration file.

Updated the package information (setup.py, MANIFEST) to include the CLI
client data.

Modified the behaviour of the XMLRPC methods registered in the *XMLRPC classes
within the daemon module. Now instead of raising exceptions directly, they
catch such exceptions, returning only a string representation of the error
to the XMLRPC client. If there is no error, a nice "ok" message is returned.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mailjam/daemon.py

    r20 r23  
    163163    def _listMethods(self):
    164164        public_methods = []
    165         public_methods += ['lists.'+i for i in dir(MailingListXMLRPC) if '_' not in i]
    166         public_methods += ['members.'+i for i in dir(MemberXMLRPC) if '_' not in i]
     165        public_methods += ['lists.'+i for i in dir(MailingListXMLRPC) \
     166                           if '_' not in i]
     167        public_methods += ['members.'+i for i in dir(MemberXMLRPC) \
     168                           if '_' not in i]
    167169        return public_methods
    168170
     
    177179        self.mailjam.load()
    178180    def add(self, info={}):
    179         self.mailjam.add_mailing_list(info)
     181        try:
     182            self.mailjam.add_mailing_list(info)
     183        except IndexError, e:
     184            return str(e)
     185        return 'Added mailing list ' + info['address'] 
    180186    def addresses(self):
    181         return self.mailjam.mailings_addresses   
     187        return self.mailjam.mailings_addresses
    182188
    183189
     
    187193        self.mailjam.load()
    188194    def add(self, member_addr=None, list_addr=None):
    189         self.mailjam.add_mailing_member(member_addr, list_addr)
     195        try:
     196            self.mailjam.add_mailing_member(member_addr, list_addr)
     197        except IndexError, e:
     198            return str(e)
     199        return 'Added member ' + member_addr + ' to ' + list_addr
    190200    def list(self, mailing):
    191201        if mailing in self.mailjam.mailings_addresses:
Note: See TracChangeset for help on using the changeset viewer.