diff options
| author | Barry Warsaw | 2007-08-02 10:47:56 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2007-08-02 10:47:56 -0400 |
| commit | ec734fab4791c107610caf73931e570b2d1b6bd0 (patch) | |
| tree | 72f27a494449a58b671ad39e5315cee5c29f64c2 | |
| parent | b2ce38ca3bf73010794860e969f6006ce632f151 (diff) | |
| download | mailman-ec734fab4791c107610caf73931e570b2d1b6bd0.tar.gz mailman-ec734fab4791c107610caf73931e570b2d1b6bd0.tar.zst mailman-ec734fab4791c107610caf73931e570b2d1b6bd0.zip | |
41 files changed, 158 insertions, 170 deletions
diff --git a/Mailman/Handlers/Hold.py b/Mailman/Handlers/Hold.py index 0db0a5c94..5c4144f47 100644 --- a/Mailman/Handlers/Hold.py +++ b/Mailman/Handlers/Hold.py @@ -42,7 +42,7 @@ from Mailman import Message from Mailman import Utils from Mailman import i18n from Mailman.configuration import config -from Mailman.interfaces import IPendable, IPending +from Mailman.interfaces import IPendable log = logging.getLogger('mailman.vette') @@ -249,7 +249,7 @@ def hold_for_approval(mlist, msg, msgdata, exc): # bounce processing that might be needed. pendable = HeldMessagePendable(type=HeldMessagePendable.PEND_KEY, id=str(id)) - token = IPending(config.db).add(pendable) + token = config.db.pendings.add(pendable) # Get the language to send the response in. If the sender is a member, # then send it in the member's language, otherwise send it in the mailing # list's preferred language. diff --git a/Mailman/Queue/Runner.py b/Mailman/Queue/Runner.py index 33d47ba47..7ca3cfbe5 100644 --- a/Mailman/Queue/Runner.py +++ b/Mailman/Queue/Runner.py @@ -147,7 +147,7 @@ class Runner: # # Find out which mailing list this message is destined for. listname = msgdata.get('listname') - mlist = config.list_manager.get(listname) + mlist = config.db.list_manager.get(listname) if not mlist: log.error('Dequeuing message destined for missing list: %s', listname) diff --git a/Mailman/app/registrar.py b/Mailman/app/registrar.py index e44394134..b3aca9c0b 100644 --- a/Mailman/app/registrar.py +++ b/Mailman/app/registrar.py @@ -32,7 +32,7 @@ from Mailman.Message import UserNotification from Mailman.Utils import ValidateEmail from Mailman.configuration import config from Mailman.i18n import _ -from Mailman.interfaces import IDomain, IPendable, IPending, IRegistrar +from Mailman.interfaces import IDomain, IPendable, IRegistrar __i18n_templates__ = True @@ -57,7 +57,7 @@ class Registrar: ValidateEmail(address) # Check to see if there is already a verified IAddress in the database # matching this address. If so, there's nothing to do. - usermgr = config.user_manager + usermgr = config.db.user_manager addr = usermgr.get_address(address) if addr and addr.verified_on: # Before returning, see if this address is linked to a user. If @@ -73,8 +73,7 @@ class Registrar: pendable = PendableRegistration(type=PendableRegistration.PEND_KEY, address=address, real_name=real_name) - pendingdb = IPending(config.db) - token = pendingdb.add(pendable) + token = config.db.pendings.add(pendable) # Set up some local variables for translation interpolation. domain = IDomain(self._context) domain_name = _(domain.domain_name) @@ -96,8 +95,7 @@ class Registrar: def confirm(self, token): """See `IUserRegistrar`.""" # For convenience - pendingdb = IPending(config.db) - pendable = pendingdb.confirm(token) + pendable = config.db.pendings.confirm(token) if pendable is None: return False missing = object() @@ -114,7 +112,7 @@ class Registrar: # We are going to end up with an IAddress for the verified address # and an IUser linked to this IAddress. See if any of these objects # currently exist in our database. - usermgr = config.user_manager + usermgr = config.db.user_manager addr = usermgr.get_address(address) user = usermgr.get_user(address) # If there is neither an address nor a user matching the confirmed @@ -144,6 +142,5 @@ class Registrar: return True def discard(self, token): - pendingdb = IPending(config.db) # Throw the record away. - pendingdb.confirm(token) + config.db.pendings.confirm(token) diff --git a/Mailman/database/__init__.py b/Mailman/database/__init__.py index e27ad8cf1..db105e21d 100644 --- a/Mailman/database/__init__.py +++ b/Mailman/database/__init__.py @@ -50,6 +50,7 @@ class StockDatabase: self.list_manager = None self.user_manager = None self.message_store = None + self.pendings = None def initialize(self): from Mailman.LockFile import LockFile @@ -63,13 +64,8 @@ class StockDatabase: self.list_manager = ListManager() self.user_manager = UserManager() self.message_store = MessageStore() + self.pendings = Pendings() self.flush() def flush(self): objectstore.flush() - - def __conform__(self, protocol): - if protocol is IPending: - return Pendings() - # Let the rest of the adaptation machinery take a crack at it. - return None diff --git a/Mailman/docs/ack-headers.txt b/Mailman/docs/ack-headers.txt index 1e335ad20..156a9d530 100644 --- a/Mailman/docs/ack-headers.txt +++ b/Mailman/docs/ack-headers.txt @@ -12,7 +12,7 @@ is getting sent through the system. We'll take things one-by-one. >>> from Mailman.Handlers.CookHeaders import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.subject_prefix = u'' >>> flush() diff --git a/Mailman/docs/acknowledge.txt b/Mailman/docs/acknowledge.txt index e22bf3d57..e9242fb45 100644 --- a/Mailman/docs/acknowledge.txt +++ b/Mailman/docs/acknowledge.txt @@ -10,7 +10,7 @@ acknowledgment. >>> from Mailman.Handlers.Acknowledge import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.real_name = 'XTest' >>> mlist.preferred_language = 'en' >>> # XXX This will almost certainly change once we've worked out the web @@ -27,8 +27,9 @@ acknowledgment. Subscribe a user to the mailing list. + >>> usermgr = config.db.user_manager >>> from Mailman.constants import MemberRole - >>> user_1 = config.user_manager.create_user('aperson@example.com') + >>> user_1 = usermgr.create_user('aperson@example.com') >>> address_1 = list(user_1.addresses)[0] >>> address_1.subscribe(mlist, MemberRole.member) <Member: aperson@example.com on _xtest@example.com as MemberRole.member> @@ -77,7 +78,7 @@ Similarly if the original sender is specified in the message metadata, and that sender is a member but not one who has requested acknowledgments, none will be sent. - >>> user_2 = config.user_manager.create_user('dperson@example.com') + >>> user_2 = usermgr.create_user('dperson@example.com') >>> address_2 = list(user_2.addresses)[0] >>> address_2.subscribe(mlist, MemberRole.member) <Member: dperson@example.com on _xtest@example.com as MemberRole.member> diff --git a/Mailman/docs/addresses.txt b/Mailman/docs/addresses.txt index aa3f3a5a3..d38bad34b 100644 --- a/Mailman/docs/addresses.txt +++ b/Mailman/docs/addresses.txt @@ -8,7 +8,7 @@ about. Addresses are subscribed to mailing lists though members. >>> from Mailman.database import flush >>> from Mailman.configuration import config - >>> mgr = config.user_manager + >>> usermgr = config.db.user_manager Creating addresses @@ -17,14 +17,14 @@ Creating addresses Addresses are created directly through the user manager, which starts out with no addresses. - >>> sorted(address.address for address in mgr.addresses) + >>> sorted(address.address for address in usermgr.addresses) [] Creating an unlinked email address is straightforward. - >>> address_1 = mgr.create_address('aperson@example.com') + >>> address_1 = usermgr.create_address('aperson@example.com') >>> flush() - >>> sorted(address.address for address in mgr.addresses) + >>> sorted(address.address for address in usermgr.addresses) ['aperson@example.com'] However, such addresses have no real name. @@ -34,11 +34,11 @@ However, such addresses have no real name. You can also create an email address object with a real name. - >>> address_2 = mgr.create_address('bperson@example.com', 'Ben Person') + >>> address_2 = usermgr.create_address('bperson@example.com', 'Ben Person') >>> flush() - >>> sorted(address.address for address in mgr.addresses) + >>> sorted(address.address for address in usermgr.addresses) ['aperson@example.com', 'bperson@example.com'] - >>> sorted(address.real_name for address in mgr.addresses) + >>> sorted(address.real_name for address in usermgr.addresses) ['', 'Ben Person'] The str() of the address is the RFC 2822 preferred originator format, while @@ -53,34 +53,34 @@ You can assign real names to existing addresses. >>> address_1.real_name = 'Anne Person' >>> flush() - >>> sorted(address.real_name for address in mgr.addresses) + >>> sorted(address.real_name for address in usermgr.addresses) ['Anne Person', 'Ben Person'] These addresses are not linked to users, and can be seen by searching the user manager for an associated user. - >>> print mgr.get_user('aperson@example.com') + >>> print usermgr.get_user('aperson@example.com') None - >>> print mgr.get_user('bperson@example.com') + >>> print usermgr.get_user('bperson@example.com') None You can create email addresses that are linked to users by using a different interface. - >>> user_1 = mgr.create_user('cperson@example.com', 'Claire Person') + >>> user_1 = usermgr.create_user('cperson@example.com', 'Claire Person') >>> flush() - >>> sorted(address.address for address in mgr.addresses) + >>> sorted(address.address for address in usermgr.addresses) ['aperson@example.com', 'bperson@example.com', 'cperson@example.com'] - >>> sorted(address.real_name for address in mgr.addresses) + >>> sorted(address.real_name for address in usermgr.addresses) ['Anne Person', 'Ben Person', 'Claire Person'] And now you can find the associated user. - >>> print mgr.get_user('aperson@example.com') + >>> print usermgr.get_user('aperson@example.com') None - >>> print mgr.get_user('bperson@example.com') + >>> print usermgr.get_user('bperson@example.com') None - >>> mgr.get_user('cperson@example.com') + >>> usermgr.get_user('cperson@example.com') <User "Claire Person" at ...> @@ -89,11 +89,11 @@ Deleting addresses You can remove an unlinked address from the usre manager. - >>> mgr.delete_address(address_1) + >>> usermgr.delete_address(address_1) >>> flush() - >>> sorted(address.address for address in mgr.addresses) + >>> sorted(address.address for address in usermgr.addresses) ['bperson@example.com', 'cperson@example.com'] - >>> sorted(address.real_name for address in mgr.addresses) + >>> sorted(address.real_name for address in usermgr.addresses) ['Ben Person', 'Claire Person'] Deleting a linked address does not delete the user, but it does unlink the @@ -104,13 +104,13 @@ address from the user. >>> user_1.controls('cperson@example.com') True >>> address_3 = list(user_1.addresses)[0] - >>> mgr.delete_address(address_3) + >>> usermgr.delete_address(address_3) >>> flush() >>> sorted(address.address for address in user_1.addresses) [] >>> user_1.controls('cperson@example.com') False - >>> sorted(address.address for address in mgr.addresses) + >>> sorted(address.address for address in usermgr.addresses) ['bperson@example.com'] @@ -120,7 +120,7 @@ Registration and validation Addresses have two dates, the date the address was registered on and the date the address was validated on. Neither date is set by default. - >>> address_4 = mgr.create_address('dperson@example.com', 'Dan Person') + >>> address_4 = usermgr.create_address('dperson@example.com', 'Dan Person') >>> flush() >>> print address_4.registered_on None @@ -153,8 +153,8 @@ Subscriptions Addresses get subscribed to mailing lists, not users. When the address is subscribed, a role is specified. - >>> address_5 = mgr.create_address('eperson@example.com', 'Elly Person') - >>> mlist = config.list_manager.create('_xtext@example.com') + >>> address_5 = usermgr.create_address('eperson@example.com', 'Elly Person') + >>> mlist = config.db.list_manager.create('_xtext@example.com') >>> from Mailman.constants import MemberRole >>> address_5.subscribe(mlist, MemberRole.owner) <Member: Elly Person <eperson@example.com> on @@ -192,7 +192,8 @@ Mailman preserves the case of addresses and uses the case preserved version when sending the user a message, but it treats addresses that are different in case equivalently in all other situations. - >>> address_6 = mgr.create_address('FPERSON@example.com', 'Frank Person') + >>> address_6 = usermgr.create_address( + ... 'FPERSON@example.com', 'Frank Person') >>> flush() The str() of such an address prints the RFC 2822 preferred originator format @@ -216,15 +217,15 @@ case-preserved version are available on attributes of the IAddress object. Because addresses are case-insensitive for all other purposes, you cannot create an address that differs only in case. - >>> mgr.create_address('fperson@example.com') + >>> usermgr.create_address('fperson@example.com') Traceback (most recent call last): ... ExistingAddressError: FPERSON@example.com - >>> mgr.create_address('fperson@EXAMPLE.COM') + >>> usermgr.create_address('fperson@EXAMPLE.COM') Traceback (most recent call last): ... ExistingAddressError: FPERSON@example.com - >>> mgr.create_address('FPERSON@example.com') + >>> usermgr.create_address('FPERSON@example.com') Traceback (most recent call last): ... ExistingAddressError: FPERSON@example.com @@ -232,7 +233,7 @@ create an address that differs only in case. You can get the address using either the lower cased version or case-preserved version. In fact, searching for an address is case insensitive. - >>> mgr.get_address('fperson@example.com').address + >>> usermgr.get_address('fperson@example.com').address 'fperson@example.com' - >>> mgr.get_address('FPERSON@example.com').address + >>> usermgr.get_address('FPERSON@example.com').address 'fperson@example.com' diff --git a/Mailman/docs/after-delivery.txt b/Mailman/docs/after-delivery.txt index 334b2b506..4304891e2 100644 --- a/Mailman/docs/after-delivery.txt +++ b/Mailman/docs/after-delivery.txt @@ -11,7 +11,7 @@ bookkeeping pieces of information are updated. >>> from Mailman.Handlers.AfterDelivery import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> post_time = datetime.datetime.now() - datetime.timedelta(minutes=10) >>> mlist.last_post_time = post_time >>> mlist.post_id = 10 diff --git a/Mailman/docs/antispam.txt b/Mailman/docs/antispam.txt index 1fce25338..cdbda4efd 100644 --- a/Mailman/docs/antispam.txt +++ b/Mailman/docs/antispam.txt @@ -15,7 +15,7 @@ measures. >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from email import message_from_string - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() diff --git a/Mailman/docs/archives.txt b/Mailman/docs/archives.txt index 1bed66e1a..e7c84a8ed 100644 --- a/Mailman/docs/archives.txt +++ b/Mailman/docs/archives.txt @@ -13,7 +13,7 @@ processes. >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from email import message_from_string - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = 'en' >>> flush() >>> switchboard = Switchboard(config.ARCHQUEUE_DIR) diff --git a/Mailman/docs/avoid-duplicates.txt b/Mailman/docs/avoid-duplicates.txt index d28f77dba..26561e455 100644 --- a/Mailman/docs/avoid-duplicates.txt +++ b/Mailman/docs/avoid-duplicates.txt @@ -11,14 +11,14 @@ recipients from the list of recipients that earlier handler modules >>> from Mailman.Handlers.AvoidDuplicates import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() Create some members we're going to use. >>> from Mailman.constants import MemberRole - >>> address_a = config.user_manager.create_address('aperson@example.com') - >>> address_b = config.user_manager.create_address('bperson@example.com') + >>> address_a = config.db.user_manager.create_address('aperson@example.com') + >>> address_b = config.db.user_manager.create_address('bperson@example.com') >>> member_a = address_a.subscribe(mlist, MemberRole.member) >>> member_b = address_b.subscribe(mlist, MemberRole.member) >>> flush() diff --git a/Mailman/docs/bounces.txt b/Mailman/docs/bounces.txt index c224abcad..aa1639e5a 100644 --- a/Mailman/docs/bounces.txt +++ b/Mailman/docs/bounces.txt @@ -15,7 +15,7 @@ lists can bounce a message with an optional error message. >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = u'en' >>> flush() diff --git a/Mailman/docs/calc-recips.txt b/Mailman/docs/calc-recips.txt index 89742d9f7..381527efb 100644 --- a/Mailman/docs/calc-recips.txt +++ b/Mailman/docs/calc-recips.txt @@ -10,19 +10,20 @@ modules and depends on a host of factors. >>> from Mailman.Handlers.CalcRecips import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() Recipients are calculate from the list members, so add a bunch of members to start out with. First, create a bunch of addresses... - >>> address_a = config.user_manager.create_address('aperson@example.com') - >>> address_b = config.user_manager.create_address('bperson@example.com') - >>> address_c = config.user_manager.create_address('cperson@example.com') - >>> address_d = config.user_manager.create_address('dperson@example.com') - >>> address_e = config.user_manager.create_address('eperson@example.com') - >>> address_f = config.user_manager.create_address('fperson@example.com') + >>> usermgr = config.db.user_manager + >>> address_a = usermgr.create_address('aperson@example.com') + >>> address_b = usermgr.create_address('bperson@example.com') + >>> address_c = usermgr.create_address('cperson@example.com') + >>> address_d = usermgr.create_address('dperson@example.com') + >>> address_e = usermgr.create_address('eperson@example.com') + >>> address_f = usermgr.create_address('fperson@example.com') ...then subscribe these addresses to the mailing list as members... diff --git a/Mailman/docs/cleanse.txt b/Mailman/docs/cleanse.txt index 99c8ca71f..ce0a69b23 100644 --- a/Mailman/docs/cleanse.txt +++ b/Mailman/docs/cleanse.txt @@ -10,7 +10,7 @@ headers can be used to fish for membership. >>> from Mailman.Handlers.Cleanse import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() Headers such as Approved, Approve, and Urgent are used to grant special diff --git a/Mailman/docs/cook-headers.txt b/Mailman/docs/cook-headers.txt index fd7a458c7..4f8885e79 100644 --- a/Mailman/docs/cook-headers.txt +++ b/Mailman/docs/cook-headers.txt @@ -12,7 +12,7 @@ is getting sent through the system. We'll take things one-by-one. >>> from Mailman.Handlers.CookHeaders import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.subject_prefix = u'' >>> mlist.include_list_post_header = False >>> mlist.archive = True diff --git a/Mailman/docs/decorate.txt b/Mailman/docs/decorate.txt index fc2f9a9f3..bf0adddd7 100644 --- a/Mailman/docs/decorate.txt +++ b/Mailman/docs/decorate.txt @@ -9,7 +9,7 @@ of the mailing list and the type of message being processed. >>> from Mailman.Handlers.Decorate import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() >>> msg_text = """\ ... From: aperson@example.org diff --git a/Mailman/docs/digests.txt b/Mailman/docs/digests.txt index 3f6bcea3c..5eb2e7364 100644 --- a/Mailman/docs/digests.txt +++ b/Mailman/docs/digests.txt @@ -12,7 +12,7 @@ digests, although only two are currently supported: MIME digests and RFC 1153 >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from email import message_from_string - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = 'en' >>> mlist.web_page_url = 'http://www.example.com/' >>> mlist.real_name = 'XTest' diff --git a/Mailman/docs/file-recips.txt b/Mailman/docs/file-recips.txt index 2c42d3dd4..8561409b6 100644 --- a/Mailman/docs/file-recips.txt +++ b/Mailman/docs/file-recips.txt @@ -10,7 +10,7 @@ list's data directory. >>> from Mailman.Handlers.FileRecips import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() @@ -84,7 +84,7 @@ their address is in the include file, the sender's address is /not/ included in the recipients list. >>> from Mailman.constants import MemberRole - >>> address_1 = config.user_manager.create_address('cperson@example.com') + >>> address_1 = config.db.user_manager.create_address('cperson@example.com') >>> address_1.subscribe(mlist, MemberRole.member) <Member: cperson@example.com on _xtest@example.com as MemberRole.member> >>> flush() diff --git a/Mailman/docs/filtering.txt b/Mailman/docs/filtering.txt index fcd59be7c..5477dd404 100644 --- a/Mailman/docs/filtering.txt +++ b/Mailman/docs/filtering.txt @@ -11,7 +11,7 @@ handlers can potentially do other kinds of finer level content filtering. >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from email import message_from_string - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = 'en' >>> flush() diff --git a/Mailman/docs/hold.txt b/Mailman/docs/hold.txt index 9574a7935..d7ae9b603 100644 --- a/Mailman/docs/hold.txt +++ b/Mailman/docs/hold.txt @@ -11,7 +11,7 @@ are held when they meet any of a number of criteria. >>> from Mailman.Queue.Switchboard import Switchboard >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = 'en' >>> mlist.real_name = '_XTest' >>> # XXX This will almost certainly change once we've worked out the web @@ -353,8 +353,7 @@ first item is a type code and the second item is a message id. ... if mo: ... cookie = mo.group('cookie') ... break - >>> from Mailman.interfaces import IPending - >>> data = IPending(config.db).confirm(cookie) + >>> data = config.db.pendings.confirm(cookie) >>> sorted(data.items()) [('id', '...'), ('type', 'held message')] >>> filename = 'heldmsg-_xtest@example.com-%s.pck' % data['id'] diff --git a/Mailman/docs/listmanager.txt b/Mailman/docs/listmanager.txt index 03943a237..653cf40f2 100644 --- a/Mailman/docs/listmanager.txt +++ b/Mailman/docs/listmanager.txt @@ -9,9 +9,9 @@ on the global config object. >>> from Mailman.database import flush >>> from Mailman.configuration import config >>> from Mailman.interfaces import IListManager - >>> IListManager.providedBy(config.list_manager) + >>> listmgr = config.db.list_manager + >>> IListManager.providedBy(listmgr) True - >>> mgr = config.list_manager Creating a mailing list @@ -20,7 +20,7 @@ Creating a mailing list Creating the list returns the newly created IMailList object. >>> from Mailman.interfaces import IMailingList - >>> mlist = mgr.create('_xtest@example.com') + >>> mlist = listmgr.create('_xtest@example.com') >>> flush() >>> IMailingList.providedBy(mlist) True @@ -45,7 +45,7 @@ list to the system. If you try to create a mailing list with the same name as an existing list, you will get an exception. - >>> mlist_dup = mgr.create('_xtest@example.com') + >>> mlist_dup = listmgr.create('_xtest@example.com') Traceback (most recent call last): ... MMListAlreadyExistsError: _xtest@example.com @@ -56,9 +56,9 @@ Deleting a mailing list Use the list manager to delete a mailing list. - >>> mgr.delete(mlist) + >>> listmgr.delete(mlist) >>> flush() - >>> sorted(mgr.names) + >>> sorted(listmgr.names) [] Attempting to access attributes of the deleted mailing list raises an @@ -71,7 +71,7 @@ exception: After deleting the list, you can create it again. - >>> mlist = mgr.create('_xtest@example.com') + >>> mlist = listmgr.create('_xtest@example.com') >>> flush() >>> mlist.fqdn_listname '_xtest@example.com' @@ -83,14 +83,14 @@ Retrieving a mailing list When a mailing list exists, you can ask the list manager for it and you will always get the same object back. - >>> mlist_2 = mgr.get('_xtest@example.com') + >>> mlist_2 = listmgr.get('_xtest@example.com') >>> mlist_2 is mlist True Don't try to get a list that doesn't exist yet though, or you will get an exception. - >>> mgr.get('_xtest_2@example.com') + >>> listmgr.get('_xtest_2@example.com') Traceback (most recent call last): ... MMUnknownListError: _xtest_2@example.com @@ -102,18 +102,18 @@ Iterating over all mailing lists Once you've created a bunch of mailing lists, you can use the list manager to iterate over either the list objects, or the list names. - >>> mlist_3 = mgr.create('_xtest_3@example.com') - >>> mlist_4 = mgr.create('_xtest_4@example.com') + >>> mlist_3 = listmgr.create('_xtest_3@example.com') + >>> mlist_4 = listmgr.create('_xtest_4@example.com') >>> flush() - >>> sorted(mgr.names) + >>> sorted(listmgr.names) ['_xtest@example.com', '_xtest_3@example.com', '_xtest_4@example.com'] - >>> sorted(m.fqdn_listname for m in mgr.mailing_lists) + >>> sorted(m.fqdn_listname for m in listmgr.mailing_lists) ['_xtest@example.com', '_xtest_3@example.com', '_xtest_4@example.com'] Cleaning up ----------- - >>> for mlist in mgr.mailing_lists: - ... mgr.delete(mlist) + >>> for mlist in listmgr.mailing_lists: + ... listmgr.delete(mlist) >>> flush() diff --git a/Mailman/docs/membership.txt b/Mailman/docs/membership.txt index 1182030ed..ee322780c 100644 --- a/Mailman/docs/membership.txt +++ b/Mailman/docs/membership.txt @@ -16,7 +16,7 @@ When we create a mailing list, it starts out with no members... >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() >>> mlist <mailing list "_xtest@example.com" (unlocked) at ...> @@ -65,8 +65,8 @@ the list's moderators. We can add new owners or moderators to this list by assigning roles to users. First we have to create the user, because there are no users in the user database yet. - >>> user_1 = config.user_manager.create_user( - ... 'aperson@example.com', 'Anne Person') + >>> usermgr = config.db.user_manager + >>> user_1 = usermgr.create_user('aperson@example.com', 'Anne Person') >>> flush() >>> user_1.real_name 'Anne Person' @@ -104,8 +104,7 @@ her a moderator. Nor does it make her a member of the list. We can add Ben as a moderator of the list, by creating a different member role for him. - >>> user_2 = config.user_manager.create_user( - ... 'bperson@example.com', 'Ben Person') + >>> user_2 = usermgr.create_user('bperson@example.com', 'Ben Person') >>> flush() >>> user_2.real_name 'Ben Person' @@ -144,8 +143,7 @@ delivery. Without a preference, Mailman will fall back first to the address's preference, then the user's preference, then the list's preference. Start without any member preference to see the system defaults. - >>> user_3 = config.user_manager.create_user( - ... 'cperson@example.com', 'Claire Person') + >>> user_3 = usermgr.create_user('cperson@example.com', 'Claire Person') >>> flush() >>> user_3.real_name 'Claire Person' diff --git a/Mailman/docs/message.txt b/Mailman/docs/message.txt index 9cca6ea96..f0f8c7739 100644 --- a/Mailman/docs/message.txt +++ b/Mailman/docs/message.txt @@ -14,7 +14,7 @@ requires a mailing list instance. >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = u'en' >>> flush() diff --git a/Mailman/docs/messagestore.txt b/Mailman/docs/messagestore.txt index ace95e914..9ed5be821 100644 --- a/Mailman/docs/messagestore.txt +++ b/Mailman/docs/messagestore.txt @@ -13,7 +13,7 @@ X-List-ID-Hash collides. >>> from email import message_from_string >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> store = config.message_store + >>> store = config.db.message_store If you try to add a message to the store which is missing either the Message-ID header or the Date header, you will get a ValueError. diff --git a/Mailman/docs/mlist-addresses.txt b/Mailman/docs/mlist-addresses.txt index be9c76787..3501524a4 100644 --- a/Mailman/docs/mlist-addresses.txt +++ b/Mailman/docs/mlist-addresses.txt @@ -7,7 +7,7 @@ These are defined in the IMailingListAddresses interface. >>> from Mailman.configuration import config >>> from Mailman.interfaces import IMailingListAddresses >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() >>> IMailingListAddresses.providedBy(mlist) True diff --git a/Mailman/docs/news-runner.txt b/Mailman/docs/news-runner.txt index 2635710a8..8189d218d 100644 --- a/Mailman/docs/news-runner.txt +++ b/Mailman/docs/news-runner.txt @@ -11,7 +11,7 @@ was originally written to gate to Usenet, which has its own rules). >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from Mailman.Queue.NewsRunner import prepare_message - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.linked_newsgroup = 'comp.lang.python' >>> flush() diff --git a/Mailman/docs/nntp.txt b/Mailman/docs/nntp.txt index 034cb7314..e169f575a 100644 --- a/Mailman/docs/nntp.txt +++ b/Mailman/docs/nntp.txt @@ -11,7 +11,7 @@ NNTP is to Usenet as IP is to the web, it's more general than that. >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from email import message_from_string - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = 'en' >>> flush() >>> switchboard = Switchboard(config.NEWSQUEUE_DIR) diff --git a/Mailman/docs/outgoing.txt b/Mailman/docs/outgoing.txt index 4dbc480fb..edbde280c 100644 --- a/Mailman/docs/outgoing.txt +++ b/Mailman/docs/outgoing.txt @@ -15,7 +15,7 @@ headers for unambigous bounce processing. >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from email import message_from_string - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> flush() >>> switchboard = Switchboard(config.OUTQUEUE_DIR) diff --git a/Mailman/docs/pending.txt b/Mailman/docs/pending.txt index 4bdd7dec3..de6326219 100644 --- a/Mailman/docs/pending.txt +++ b/Mailman/docs/pending.txt @@ -15,7 +15,7 @@ This is not where messages held for administrator approval are kept. In order to pend an event, you first need a pending database, which is available by adapting the list manager. - >>> pendingdb = IPending(config.db) + >>> pendingdb = config.db.pendings >>> verifyObject(IPending, pendingdb) True diff --git a/Mailman/docs/registration.txt b/Mailman/docs/registration.txt index 1d59f184b..a98a320af 100644 --- a/Mailman/docs/registration.txt +++ b/Mailman/docs/registration.txt @@ -112,7 +112,7 @@ returned. There should be no records in the user manager for this address yet. - >>> usermgr = config.user_manager + >>> usermgr = config.db.user_manager >>> print usermgr.get_user('aperson@example.com') None >>> print usermgr.get_address('aperson@example.com') @@ -120,8 +120,7 @@ There should be no records in the user manager for this address yet. But this address is waiting for confirmation. - >>> from Mailman.interfaces import IPending - >>> pendingdb = IPending(config.db) + >>> pendingdb = config.db.pendings >>> sorted(pendingdb.confirm(token, expunge=False).items()) [('address', 'aperson@example.com'), ('real_name', 'Anne Person'), @@ -358,8 +357,7 @@ Likewise, if you try to confirm, through the IUserRegistrar interface, a token that doesn't match a registration even, you will get None. However, the pending even matched with that token will still be removed. - >>> from Mailman.interfaces import IPendable, IPending - >>> pendingdb = IPending(config.db) + >>> from Mailman.interfaces import IPendable >>> class SimplePendable(dict): ... implements(IPendable) >>> pendable = SimplePendable(type='foo', bar='baz') diff --git a/Mailman/docs/reply-to.txt b/Mailman/docs/reply-to.txt index c6b06a390..6ab477f79 100644 --- a/Mailman/docs/reply-to.txt +++ b/Mailman/docs/reply-to.txt @@ -12,7 +12,7 @@ is getting sent through the system. We'll take things one-by-one. >>> from Mailman.Handlers.CookHeaders import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.subject_prefix = u'' >>> flush() diff --git a/Mailman/docs/replybot.txt b/Mailman/docs/replybot.txt index e0c44180f..2db4e4b07 100644 --- a/Mailman/docs/replybot.txt +++ b/Mailman/docs/replybot.txt @@ -11,7 +11,7 @@ message or the amount of time since the last auto-response. >>> from Mailman.Message import Message >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.real_name = 'XTest' >>> flush() diff --git a/Mailman/docs/runner.txt b/Mailman/docs/runner.txt index 26fbed405..fc5299c2a 100644 --- a/Mailman/docs/runner.txt +++ b/Mailman/docs/runner.txt @@ -21,7 +21,7 @@ continuously in a loop until the .stop() method is called. >>> from Mailman.Queue.Switchboard import Switchboard >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = 'en' >>> flush() diff --git a/Mailman/docs/scrubber.txt b/Mailman/docs/scrubber.txt index 0e13f78a2..344894666 100644 --- a/Mailman/docs/scrubber.txt +++ b/Mailman/docs/scrubber.txt @@ -11,7 +11,7 @@ archive message. >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from email import message_from_string - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.preferred_language = 'en' >>> flush() diff --git a/Mailman/docs/subject-munging.txt b/Mailman/docs/subject-munging.txt index e74da47d6..1ceebd415 100644 --- a/Mailman/docs/subject-munging.txt +++ b/Mailman/docs/subject-munging.txt @@ -12,7 +12,7 @@ is getting sent through the system. We'll take things one-by-one. >>> from Mailman.Handlers.CookHeaders import process >>> from Mailman.configuration import config >>> from Mailman.database import flush - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') >>> mlist.subject_prefix = u'' >>> flush() diff --git a/Mailman/docs/tagger.txt b/Mailman/docs/tagger.txt index 1d576b9ae..f220cdcc6 100644 --- a/Mailman/docs/tagger.txt +++ b/Mailman/docs/tagger.txt @@ -14,7 +14,7 @@ expressions. The message then gets tagged with the topic names of each hit. >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from email import message_from_string - >>> mlist = config.list_manager.create('_xtest@example.com') + >>> mlist = config.db.list_manager.create('_xtest@example.com') Topics must be enabled for Mailman to do any topic matching, even if topics are defined. diff --git a/Mailman/docs/usermanager.txt b/Mailman/docs/usermanager.txt index 4fd12bf59..b8a9d2e66 100644 --- a/Mailman/docs/usermanager.txt +++ b/Mailman/docs/usermanager.txt @@ -9,8 +9,9 @@ config object. >>> from Mailman.configuration import config >>> from Mailman.database import flush >>> from Mailman.interfaces import IUserManager - >>> mgr = config.user_manager - >>> IUserManager.providedBy(mgr) + >>> from zope.interface.verify import verifyObject + >>> usermgr = config.db.user_manager + >>> verifyObject(IUserManager, usermgr) True @@ -23,9 +24,9 @@ time. This user will have an empty string as their real name, but will not have a password. >>> from Mailman.interfaces import IUser - >>> user = mgr.create_user() + >>> user = usermgr.create_user() >>> flush() - >>> IUser.providedBy(user) + >>> verifyObject(IUser, user) True >>> sorted(address.address for address in user.addresses) [] @@ -43,56 +44,56 @@ A user can be assigned a real name. >>> user.real_name = 'Anne Person' >>> flush() - >>> sorted(user.real_name for user in mgr.users) + >>> sorted(user.real_name for user in usermgr.users) ['Anne Person'] A user can be assigned a password. >>> user.password = 'secret' >>> flush() - >>> sorted(user.password for user in mgr.users) + >>> sorted(user.password for user in usermgr.users) ['secret'] You can also create a user with an address to start out with. - >>> user_2 = mgr.create_user('bperson@example.com') + >>> user_2 = usermgr.create_user('bperson@example.com') >>> flush() - >>> IUser.providedBy(user_2) + >>> verifyObject(IUser, user_2) True >>> sorted(address.address for address in user_2.addresses) ['bperson@example.com'] - >>> sorted(user.real_name for user in mgr.users) + >>> sorted(user.real_name for user in usermgr.users) ['', 'Anne Person'] As above, you can assign a real name to such users. >>> user_2.real_name = 'Ben Person' >>> flush() - >>> sorted(user.real_name for user in mgr.users) + >>> sorted(user.real_name for user in usermgr.users) ['Anne Person', 'Ben Person'] You can also create a user with just a real name. - >>> user_3 = mgr.create_user(real_name='Claire Person') + >>> user_3 = usermgr.create_user(real_name='Claire Person') >>> flush() - >>> IUser.providedBy(user_3) + >>> verifyObject(IUser, user_3) True >>> sorted(address.address for address in user.addresses) [] - >>> sorted(user.real_name for user in mgr.users) + >>> sorted(user.real_name for user in usermgr.users) ['Anne Person', 'Ben Person', 'Claire Person'] Finally, you can create a user with both an address and a real name. - >>> user_4 = mgr.create_user('dperson@example.com', 'Dan Person') + >>> user_4 = usermgr.create_user('dperson@example.com', 'Dan Person') >>> flush() - >>> IUser.providedBy(user_3) + >>> verifyObject(IUser, user_3) True >>> sorted(address.address for address in user_4.addresses) ['dperson@example.com'] >>> sorted(address.real_name for address in user_4.addresses) ['Dan Person'] - >>> sorted(user.real_name for user in mgr.users) + >>> sorted(user.real_name for user in usermgr.users) ['Anne Person', 'Ben Person', 'Claire Person', 'Dan Person'] @@ -102,9 +103,9 @@ Deleting users You delete users by going through the user manager. The deleted user is no longer available through the user manager iterator. - >>> mgr.delete_user(user) + >>> usermgr.delete_user(user) >>> flush() - >>> sorted(user.real_name for user in mgr.users) + >>> sorted(user.real_name for user in usermgr.users) ['Ben Person', 'Claire Person', 'Dan Person'] @@ -117,7 +118,7 @@ that the .get_user() method takes a string email address, not an IAddress object. >>> address = list(user_4.addresses)[0] - >>> found_user = mgr.get_user(address.address) + >>> found_user = usermgr.get_user(address.address) >>> found_user <User "Dan Person" at ...> >>> found_user is user_4 @@ -126,9 +127,9 @@ object. If the address is not in the user database or does not have a user associated with it, you will get None back. - >>> print mgr.get_user('zperson@example.com') + >>> print usermgr.get_user('zperson@example.com') None >>> user_4.unlink(address) >>> flush() - >>> print mgr.get_user(address.address) + >>> print usermgr.get_user(address.address) None diff --git a/Mailman/docs/users.txt b/Mailman/docs/users.txt index eb4c9df10..130c97210 100644 --- a/Mailman/docs/users.txt +++ b/Mailman/docs/users.txt @@ -9,7 +9,7 @@ See usermanager.txt for examples of how to create, delete, and find users. >>> from Mailman.database import flush >>> from Mailman.configuration import config - >>> mgr = config.user_manager + >>> usermgr = config.db.user_manager User data @@ -17,13 +17,13 @@ User data Users may have a real name and a password. - >>> user_1 = mgr.create_user() + >>> user_1 = usermgr.create_user() >>> user_1.password = 'my password' >>> user_1.real_name = 'Zoe Person' >>> flush() - >>> sorted(user.real_name for user in mgr.users) + >>> sorted(user.real_name for user in usermgr.users) ['Zoe Person'] - >>> sorted(user.password for user in mgr.users) + >>> sorted(user.password for user in usermgr.users) ['my password'] The password and real name can be changed at any time. @@ -31,9 +31,9 @@ The password and real name can be changed at any time. >>> user_1.real_name = 'Zoe X. Person' >>> user_1.password = 'another password' >>> flush() - >>> sorted(user.real_name for user in mgr.users) + >>> sorted(user.real_name for user in usermgr.users) ['Zoe X. Person'] - >>> sorted(user.password for user in mgr.users) + >>> sorted(user.password for user in usermgr.users) ['another password'] @@ -59,7 +59,7 @@ address on a user object. You can also create the address separately and then link it to the user. - >>> address_1 = mgr.create_address('zperson@example.net') + >>> address_1 = usermgr.create_address('zperson@example.net') >>> user_1.link(address_1) >>> flush() >>> sorted(address.address for address in user_1.addresses) @@ -69,7 +69,7 @@ You can also create the address separately and then link it to the user. But don't try to link an address to more than one user. - >>> another_user = mgr.create_user() + >>> another_user = usermgr.create_user() >>> another_user.link(address_1) Traceback (most recent call last): ... @@ -85,13 +85,13 @@ You can also ask whether a given user controls a given address. Given a text email address, the user manager can find the user that controls that address. - >>> mgr.get_user('zperson@example.com') is user_1 + >>> usermgr.get_user('zperson@example.com') is user_1 True - >>> mgr.get_user('zperson@example.net') is user_1 + >>> usermgr.get_user('zperson@example.net') is user_1 True - >>> mgr.get_user('zperson@example.org') is user_1 + >>> usermgr.get_user('zperson@example.org') is user_1 True - >>> print mgr.get_user('bperson@example.com') + >>> print usermgr.get_user('bperson@example.com') None Addresses can also be unlinked from a user. @@ -99,7 +99,7 @@ Addresses can also be unlinked from a user. >>> user_1.unlink(address_1) >>> user_1.controls('zperson@example.net') False - >>> print mgr.get_user('aperson@example.net') + >>> print usermgr.get_user('aperson@example.net') None But don't try to unlink the address from a user it's not linked to. diff --git a/Mailman/initialize.py b/Mailman/initialize.py index 9d16600ef..650aa925f 100644 --- a/Mailman/initialize.py +++ b/Mailman/initialize.py @@ -34,10 +34,7 @@ import Mailman.configuration import Mailman.ext import Mailman.loginit -from Mailman.interfaces import ( - IDatabase, IListManager, IMessageStore, IUserManager) - -DOT = '.' +from Mailman.interfaces import IDatabase @@ -94,12 +91,6 @@ def initialize_2(): verifyObject(IDatabase, db) db.initialize() Mailman.configuration.config.db = db - verifyObject(IListManager, db.list_manager) - Mailman.configuration.config.list_manager = db.list_manager - verifyObject(IUserManager, db.user_manager) - Mailman.configuration.config.user_manager = db.user_manager - verifyObject(IMessageStore, db.message_store) - Mailman.configuration.config.message_store = db.message_store def initialize(config=None, propagate_logs=False): diff --git a/Mailman/interfaces/database.py b/Mailman/interfaces/database.py index 86bd54ce6..23405b9e8 100644 --- a/Mailman/interfaces/database.py +++ b/Mailman/interfaces/database.py @@ -49,3 +49,6 @@ class IDatabase(Interface): message_store = Attribute( """The IMessageStore instance provided by the database layer.""") + + pendings = Attribute( + """The IPending instance provided by the database layer.""") diff --git a/Mailman/tests/test_documentation.py b/Mailman/tests/test_documentation.py index c5fb62302..bbceedcc0 100644 --- a/Mailman/tests/test_documentation.py +++ b/Mailman/tests/test_documentation.py @@ -31,24 +31,26 @@ COMMASPACE = ', ' def cleaning_teardown(testobj): + usermgr = config.db.user_manager + listmgr = config.db.list_manager # Remove all users, addresses and members, then delete all mailing lists. - for user in config.user_manager.users: - config.user_manager.delete_user(user) - for address in config.user_manager.addresses: - config.user_manager.delete_address(address) - for mlist in config.list_manager.mailing_lists: + for user in usermgr.users: + usermgr.delete_user(user) + for address in usermgr.addresses: + usermgr.delete_address(address) + for mlist in listmgr.mailing_lists: for member in mlist.members.members: member.unsubscribe() for admin in mlist.administrators.members: admin.unsubscribe() - config.list_manager.delete(mlist) + listmgr.delete(mlist) flush() - assert not list(config.list_manager.mailing_lists), ( + assert not list(listmgr.mailing_lists), ( 'There should be no mailing lists left: %s' % - COMMASPACE.join(sorted(config.list_manager.names))) - assert not list(config.user_manager.users), ( + COMMASPACE.join(sorted(listmgr.names))) + assert not list(usermgr.users), ( 'There should be no users left!') - assert not list(config.user_manager.addresses), ( + assert not list(usermgr.addresses), ( 'There should be no addresses left!') # Remove all queue files. for dirpath, dirnames, filenames in os.walk(config.QUEUE_DIR): |
