diff options
| author | cotton | 1998-11-19 13:15:09 +0000 |
|---|---|---|
| committer | cotton | 1998-11-19 13:15:09 +0000 |
| commit | f54c2fd02ba71dabf16739806fa8f7bb6a2e2d55 (patch) | |
| tree | 34f50499b9c48145fa17c70bfa474e4eede3ece2 /Mailman/MailList.py | |
| parent | f5210e33e5929228a4f24e818e24f15c2dcde0a7 (diff) | |
| download | mailman-f54c2fd02ba71dabf16739806fa8f7bb6a2e2d55.tar.gz mailman-f54c2fd02ba71dabf16739806fa8f7bb6a2e2d55.tar.zst mailman-f54c2fd02ba71dabf16739806fa8f7bb6a2e2d55.zip | |
This change implements storing list members and digest members as
dicts instead of lists, which optimizes Utils.FindMatchingAddresses
and general membership management, especially for large lists.
MailList.py now supplies .GetMembers() and .GetDigestMembers() to
supply the data in list form to anything that needs it that way.
An new install showed this worked fine with some cursory testing of
the cgi's and interactive poking around.
A detailed listing of the changes follows:
Mailman/Defaults.py.in: change data version to 11
Mailman/Digester.py: initvars now instantiates digest_members as {}
instead of []
lines 113-114 and 121-122 now use del
This change implements storing list members and digest members as
dicts instead of lists, which optimizes Utils.FindMatchingAddresses
and general membership management, especially for large lists.
MailList.py now supplies .GetMembers() and .GetDigestMembers() to
supply the data in list form to anything that needs it that way.
Though INSTALL shows up on the changed files section, a diff a few
seconds ago didn't show any differences in that file, so I hope nobody
changed it in the interim.
An new install showed this worked fine with some cursory testing of
the cgi's and interactive poking around.
A detailed listing of the changes follows:
Mailman/Defaults.py.in: change data version to 11
Mailman/Digester.py: initvars now instantiates digest_members as {}
instead of []
lines 113-114 and 121-122 now use del
list.[digest_]member instead of
list.[digest_]members.remove
when figuring who to actually send digests to,
use list.GetDigestMembers() instead of
list.digest_members.
Mailman/HTMLFormatter: now uses list.Get[Digest]Members to get
subscribers, and length of digested subscribers
and regular members
MailCommandHandler, SecurityManager,Cgi/handle_opts, Cgi/options: all
simple replacements of list.[digest_]members with
list.Get[Digest]Members().
Mailman/Cgi/admin.py: mostly simple replacements of
list.[digest_]members with the Get..() methods, however, the
membership management section now works much quicker and changes
digest->nodigest subscriptions via dictionary manipulations.
Mailman/versions.py: updates lists to use dicts and changed
list.[digest_]members to use the list.Get[Digest]Members() methods.
Mailman/Utils.py: added a function "GetPossibleMatchingAddresses"
which when fed an address, returns the list of addresses that "smart"
address matching would match.
changed FindMatchingAddresses(name, list) to use a new signature:
FindMatchingAddresses(name, *dicts), where dicts is a list of
dictionaries keyed by addresses. Just realized that this would better
be FindMatchingAddresses(name, dict, *dicts) so that it enforces
atleast 2 args... I'll make that change in a sec.
All uses of FindMatchingAddresses have been changed to fit the new
arguments.
scott
----:**-F1 cvs30458aaa 1:12PM 0.98 Mail (Text Fill)--L59--32%-------------------------------------------
?
Diffstat (limited to 'Mailman/MailList.py')
| -rw-r--r-- | Mailman/MailList.py | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py index 1fdebd3de..68d57a807 100644 --- a/Mailman/MailList.py +++ b/Mailman/MailList.py @@ -63,8 +63,17 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, for f in self._log_files.values(): f.close() + def GetMembers(self): + """returns a list of the members.""" + return self.members.keys() + + def GetDigestMembers(self): + """returns a list of digest members.""" + return self.digest_members.keys() + def GetAdminEmail(self): return '%s-admin@%s' % (self._internal_name, self.host_name) + def GetMemberAdminEmail(self, member): """Usually the member addr, but modified for umbrella lists. @@ -114,7 +123,7 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, def GetUserOption(self, user, option): if option == mm_cfg.Digests: - return user in self.digest_members + return self.digest_members.has_key(user) if not self.user_options.has_key(user): return 0 return not not self.user_options[user] & option @@ -132,8 +141,8 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, def FindUser(self, email): matches = Utils.FindMatchingAddresses(email, - (self.members - + self.digest_members)) + (self.members, + self.digest_members)) if not matches or not len(matches): return None return matches[0] @@ -157,7 +166,7 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, # Must save this state, even though it isn't configurable self.volume = 1 - self.members = [] # self.digest_members is initted in mm_digest + self.members = {} # self.digest_members is initted in mm_digest self.data_version = mm_cfg.VERSION self.last_post_time = 0 @@ -767,10 +776,10 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, if self.IsMember(name): raise Errors.MMAlreadyAMember if digest: - self.digest_members.append(name) + self.digest_members[name] = 1 kind = " (D)" else: - self.members.append(name) + self.members[name] = 1 kind = "" self.SetUserOption(name, mm_cfg.DisableMime, 1 - self.mime_is_default_digest) @@ -800,8 +809,8 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, self.IsListInitialized() # FindMatchingAddresses *should* never return more than 1 address. # However, should log this, just to make sure. - aliases = Utils.FindMatchingAddresses(name, self.members + - self.digest_members) + aliases = Utils.FindMatchingAddresses(name, self.members, + self.digest_members) if not len(aliases): raise Errors.MMNoSuchUserError @@ -814,14 +823,14 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, if me.user_options.has_key(alias): del me.user_options[alias] try: - me.members.remove(alias) + del me.members[alias] kind = "regular" - except ValueError: + except KeyError: pass try: - me.digest_members.remove(alias) + del me.digest_members[alias] kind = "digest" - except ValueError: + except KeyError: pass map(DoActualRemoval, aliases) @@ -835,8 +844,8 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, self._internal_name, name, whence) def IsMember(self, address): - return len(Utils.FindMatchingAddresses(address, self.members + - self.digest_members)) + return len(Utils.FindMatchingAddresses(address, self.members, + self.digest_members)) def HasExplicitDest(self, msg): """True if list name or any acceptable_alias is included among the @@ -1038,7 +1047,7 @@ class MailList(MailCommandHandler, HTMLFormatter, Deliverer, ListAdmin, if self.GetUserOption(sender, mm_cfg.AcknowlegePosts): ack_post = 1 # Deliver the mail. - recipients = self.members[:] + recipients = self.GetMembers() if dont_send_to_sender: try: recipients.remove(sender) |
