Changeset 16:cd4170142d87 in mailjam for mailjam/daemon.py
- Timestamp:
- May 22, 2012, 9:31:15 AM (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
mailjam/daemon.py
r15 r16 4 4 from SimpleXMLRPCServer import SimpleXMLRPCServer, list_public_methods 5 5 6 from postmanimport config7 from postman.models import Member, MailingList8 from postman.storage import JsonStorage as Storage9 10 11 class Postman():6 from mailjam import config 7 from mailjam.models import Member, MailingList 8 from mailjam.storage import JsonStorage as Storage 9 10 11 class Mailjam(): 12 12 13 13 def __init__(self, configfile=None): … … 33 33 if self.mailings: 34 34 # Save the config file from where we can reload information about 35 # the mailing lists managed by this postmaninstance35 # the mailing lists managed by this mailjam instance 36 36 self.dbs['mailings'].write(self.mailings_addresses) 37 37 # Save each mailing list data into its separated persistence file … … 64 64 Delete all stored data from disk (useful for testing). 65 65 DANGER: Calling this method will remove all data from disk, leaving the 66 postman instance with no persistence data, if the postmanprocess die,66 mailjam instance with no persistence data, if the mailjam process die, 67 67 before another .save() call is made, all data will be lost. 68 68 """ … … 76 76 def add_mailing_list(self, info={}): 77 77 """ 78 Add a new mailing list to this postmaninstance. expects one parameter,78 Add a new mailing list to this mailjam instance. expects one parameter, 79 79 info, which is a dictionary that should contain, at least, the 80 80 following keys: … … 96 96 if info['address'] in self.mailings_addresses: 97 97 raise IndexError(info['address'], 98 ' has been already added to postman')98 ' has been already added to mailjam') 99 99 100 100 mailing = MailingList(info['name'], info['address'], … … 109 109 """ 110 110 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 postman111 containing the email address of any mailing list managed by this mailjam 112 112 instance). member_addr is a string representing the email address of the 113 113 new member … … 130 130 131 131 132 class PostmanXMLRPC():132 class MailjamXMLRPC(): 133 133 """ 134 134 This class is a wrapper we will use to limit the methods that will be … … 159 159 class MailingListXMLRPC(): 160 160 def __init__(self): 161 self. postman = Postman()162 self. postman.load()161 self.mailjam = Mailjam() 162 self.mailjam.load() 163 163 def add(self, info={}): 164 self. postman.add_mailing_list(info)164 self.mailjam.add_mailing_list(info) 165 165 def addresses(self): 166 return self. postman.mailings_addresses166 return self.mailjam.mailings_addresses 167 167 168 168 169 169 class MemberXMLRPC(): 170 170 def __init__(self): 171 self. postman = Postman()172 self. postman.load()171 self.mailjam = Mailjam() 172 self.mailjam.load() 173 173 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) 175 175 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 180 class MailjamDaemon(): 181 181 def __init__(self, configfile=None): 182 182 self.config = config.get_config_parameters('xmlrpc_server', configfile) … … 211 211 """ 212 212 Check if there is an initialized server (initialize it if there is none) 213 and then register all the Postmanpublic methods to be served through213 and then register all the Mailjam public methods to be served through 214 214 the xml-rpc link 215 215 … … 221 221 msg = 'Registering public methods' 222 222 logging.info(msg) 223 root = PostmanXMLRPC()223 root = MailjamXMLRPC() 224 224 root.lists = MailingListXMLRPC() 225 225 root.members = MemberXMLRPC()
Note:
See TracChangeset
for help on using the changeset viewer.