コード例 #1
0
 def setMemberOption(self, member, flag, value):
     assert self.__mlist.Locked()
     self.__assertIsMember(member)
     memberkey = member.lower()
     # There's one extra gotcha we have to deal with.  If the user is
     # toggling the Digests flag, then we need to move their entry from
     # mlist.members to mlist.digest_members or vice versa.  Blarg.  Do
     # this before the flag setting below in case it fails.
     if flag == mm_cfg.Digests:
         if value:
             # Be sure the list supports digest delivery
             if not self.__mlist.digestable:
                 raise Errors.CantDigestError
             # The user is turning on digest mode
             if memberkey in self.__mlist.digest_members:
                 raise Errors.AlreadyReceivingDigests(member)
             cpuser = self.__mlist.members.get(memberkey)
             if cpuser is None:
                 raise Errors.NotAMemberError(member)
             del self.__mlist.members[memberkey]
             self.__mlist.digest_members[memberkey] = cpuser
             # If we recently turned off digest mode and are now
             # turning it back on, the member may be in one_last_digest.
             # If so, remove it so the member doesn't get a dup of the
             # next digest.
             if memberkey in self.__mlist.one_last_digest:
                 del self.__mlist.one_last_digest[memberkey]
         else:
             # Be sure the list supports regular delivery
             if not self.__mlist.nondigestable:
                 raise Errors.MustDigestError
             # The user is turning off digest mode
             if memberkey in self.__mlist.members:
                 raise Errors.AlreadyReceivingRegularDeliveries(member)
             cpuser = self.__mlist.digest_members.get(memberkey)
             if cpuser is None:
                 raise Errors.NotAMemberError(member)
             del self.__mlist.digest_members[memberkey]
             self.__mlist.members[memberkey] = cpuser
             # When toggling off digest delivery, we want to be sure to set
             # things up so that the user receives one last digest,
             # otherwise they may lose some email
             self.__mlist.one_last_digest[memberkey] = cpuser
         # We don't need to touch user_options because the digest state
         # isn't kept as a bitfield flag.
         return
     # This is a bit kludgey because the semantics are that if the user has
     # no options set (i.e. the value would be 0), then they have no entry
     # in the user_options dict.  We use setdefault() here, and then del
     # the entry below just to make things (questionably) cleaner.
     self.__mlist.user_options.setdefault(memberkey, 0)
     if value:
         self.__mlist.user_options[memberkey] |= flag
     else:
         self.__mlist.user_options[memberkey] &= ~flag
     if not self.__mlist.user_options[memberkey]:
         del self.__mlist.user_options[memberkey]
コード例 #2
0
 def getMemberPassword(self, member):
     secret = self.__mlist.passwords.get(member.lower())
     if secret is None:
         raise Errors.NotAMemberError(member)
     return secret
コード例 #3
0
 def getMemberCPAddress(self, member):
     cpaddr, where = self.__get_cp_member(member)
     if cpaddr is None:
         raise Errors.NotAMemberError(member)
     return cpaddr
コード例 #4
0
 def getMemberKey(self, member):
     cpaddr, where = self.__get_cp_member(member)
     if cpaddr is None:
         raise Errors.NotAMemberError(member)
     return member.lower()
コード例 #5
0
 def __assertIsMember(self, member):
     if not self.isMember(member):
         raise Errors.NotAMemberError(member)