Ticket #4151: 4151.3.patch

File 4151.3.patch, 4.7 KB (added by moijes12, 5 years ago)
  • twisted/mail/topfiles/4151.removal

     
     1twisted.mail.mail.IDomain.startMessage, deprecated since 2003, has been removed.
  • twisted/mail/mail.py

     
    1212from twisted.python import util
    1313from twisted.python import log
    1414
    15 from twisted import cred
    16 import twisted.cred.portal
     15from twisted.cred.portal import Portal
    1716
    1817# Sibling imports
    1918from twisted.mail import protocols, smtp
     
    2423
    2524
    2625class DomainWithDefaultDict:
    27     '''Simulate a dictionary with a default value for non-existing keys.
    28     '''
     26    """
     27    Simulate a dictionary with a default value for non-existing keys.
     28    """
    2929    def __init__(self, domains, default):
    3030        self.domains = domains
    3131        self.default = default
     
    115115        return self.domains.setdefault(key, default)
    116116
    117117class IDomain(Interface):
    118     """An email domain."""
     118    """
     119    An email domain.
     120    """
    119121
    120122    def exists(user):
    121123        """
    122124        Check whether or not the specified user exists in this domain.
    123125
    124         @type user: C{twisted.protocols.smtp.User}
     126        @type user: C{twisted.mail.smtp.User}
    125127        @param user: The user to check
    126128
    127129        @rtype: No-argument callable
     
    130132        This will be called and the returned object used to deliver the
    131133        message when it arrives.
    132134
    133         @raise twisted.protocols.smtp.SMTPBadRcpt: Raised if the given
     135        @raise twisted.mail.smtp.SMTPBadRcpt: Raised if the given
    134136        user does not exist in this domain.
    135137        """
    136138
    137139    def addUser(user, password):
    138         """Add a username/password to this domain."""
     140        """
     141        Add a username/password to this domain.
     142        """
    139143
    140     def startMessage(user):
    141         """Create and return a new message to be delivered to the given user.
    142144
    143         DEPRECATED.  Implement validateTo() correctly instead.
    144         """
    145 
    146145    def getCredentialsCheckers():
    147         """Return a list of ICredentialsChecker implementors for this domain.
    148146        """
     147        Return a list of ICredentialsChecker implementors for this domain.
     148        """
    149149
    150150class IAliasableDomain(IDomain):
    151151    def setAliasGroup(aliases):
    152         """Set the group of defined aliases for this domain
     152        """
     153        Set the group of defined aliases for this domain
    153154
    154155        @type aliases: C{dict}
    155156        @param aliases: Mapping of domain names to objects implementing
     
    160161        """
    161162        Check whether or not the specified user exists in this domain.
    162163
    163         @type user: C{twisted.protocols.smtp.User}
     164        @type user: C{twisted.mail.smtp.User}
    164165        @param user: The user to check
    165166
    166167        @type memo: C{dict}
     
    174175        This will be called and the returned object used to deliver the
    175176        message when it arrives.
    176177
    177         @raise twisted.protocols.smtp.SMTPBadRcpt: Raised if the given
     178        @raise twisted.mail.smtp.SMTPBadRcpt: Raised if the given
    178179        user does not exist in this domain.
    179180        """
    180181
    181182class BounceDomain:
    182     """A domain in which no user exists.
     183    """
     184    A domain in which no user exists.
    183185
    184186    This can be used to block off certain domains.
    185187    """
     
    207209
    208210
    209211class FileMessage:
    210     """A file we can write an email too."""
     212    """
     213    A file we can write an email too.
     214    """
    211215
    212216    implements(smtp.IMessage)
    213217
     
    230234
    231235
    232236class MailService(service.MultiService):
    233     """An email service."""
     237    """
     238    An email service.
     239    """
    234240
    235241    queue = None
    236242    domains = None
     
    246252
    247253        self.monitor = FileMonitoringService()
    248254        self.monitor.setServiceParent(self)
    249         self.smtpPortal = cred.portal.Portal(self)
     255        self.smtpPortal = Portal(self)
    250256
    251257    def getPOP3Factory(self):
    252258        return protocols.POP3Factory(self)
     
    258264        return protocols.ESMTPFactory(self, self.smtpPortal)
    259265
    260266    def addDomain(self, name, domain):
    261         portal = cred.portal.Portal(domain)
     267        portal = Portal(domain)
    262268        map(portal.registerChecker, domain.getCredentialsCheckers())
    263269        self.domains[name] = domain
    264270        self.portals[name] = portal
     
    266272            domain.setAliasGroup(self.aliases)
    267273
    268274    def setQueue(self, queue):
    269         """Set the queue for outgoing emails."""
     275        """
     276        Set the queue for outgoing emails.
     277        """
    270278        self.queue = queue
    271279
    272280    def requestAvatar(self, avatarId, mind, *interfaces):