Ticket #4623: 4623.2.patch

File 4623.2.patch, 4.9 KB (added by moijes12, 7 years ago)
  • twisted/mail/topfiles/4623.bugfix

     
     1Interface IQueue has been implemented.
  • twisted/mail/relaymanager.py

     
    2828except ImportError:
    2929    import pickle
    3030
     31from zope.interface import Interface, implements
     32
    3133from twisted.python import log
    3234from twisted.python.failure import Failure
    3335from twisted.python.compat import set
     
    131133        protocol.factory = self
    132134        return protocol
    133135
     136class IQueue(Interface):
     137    """
     138    A queue of mail messages to be relayed.
     139    """
     140
     141
     142    def createNewMessage():
     143        """
     144        Create a new message in the queue.
     145
     146        @return: A tuple containing the message header and a file-like object containing references to the message file.
     147        @rtype:  C{tuple}
     148        """
     149
     150
     151    def readDirectory():
     152        """
     153        Look for new messages in the messages directory adding them to queue of messages waiting to be relayed.
     154
     155        @return: C{None}
     156        @rtype:  C{NoneType}
     157        """
     158
     159
     160    def done(message):
     161        """
     162        Remove message from the queue and delete it from the file system.
     163
     164        @param message: Message to be removed.
     165        @type message: C{str}
     166        """
     167
     168
     169    def getPath(message):
     170        """
     171        Get the filesystem path of the given message.
     172
     173        @param message: Message for which the filesystem path of the file object is required
     174        @type message: C{str}
     175
     176        @return: a string representing the filesystem path where the message is stored.
     177        @rtype:  C{str}
     178        """
     179
     180
     181    def hasWaiting():
     182        """
     183        Check if there are any messages to be relayed.
     184
     185        @return: a boolean value which is C{True} if there are any messages waiting to be transferred and C{False} if there are no messages waiting to be transferred.
     186        @rtype:  C{bool}
     187        """
     188
     189
     190    def getWaiting():
     191        """
     192        Return a list of messages waiting to be relayed.
     193
     194        @return: a list of messages waiting in the queue to be relayed.
     195        @rtype:  C{list}
     196        """
     197
     198
     199    def setWaiting(message):
     200        """
     201        Add a message to the queue of messages waiting to be relayed.
     202
     203        @param message: Message to be added to the queue of messages waiting to be relayed.
     204        @type message: C{str}
     205        """
     206
     207
     208    def getRelayed():
     209        """
     210        Get the list of relayed messages.
     211
     212        @return: a list of messages relayed by the system.
     213        @rtype:  C{list}
     214        """
     215 
     216
     217    def setRelaying(message):
     218        """
     219        Add a message from the waiting queue to the queue of messages to be relayed.
     220
     221        @param message: Message to be added to the queue of messages to be relayed.
     222        @type message: C{str}
     223        """
     224
     225
     226    def getEnvelope(message):
     227        """
     228        Get a message file object for the given message.
     229
     230        @type message: C{str}
     231        @param message: Message for which the file object is to be obtained.
     232
     233        @return: Message file object for the message.
     234        @rtype:  C{object}
     235        """
     236
     237 
     238    def getEnvelopeFile(message):
     239        """
     240        Get the file handle to the message file object of a given message.
     241
     242        @type message: C{str}
     243        @param message: The message for which the file handle to its message file object is to be obtained.
     244
     245        @return: File handle of the message file object of message.
     246        @rtype: C{file}
     247        """
     248
    134249class Queue:
    135250    """A queue of ougoing emails."""
    136251
     252    implements(IQueue)
     253
    137254    noisy = True
    138255
    139256    def __init__(self, directory):
  • twisted/mail/test/test_mail.py

     
    1515import signal
    1616
    1717from zope.interface import Interface, implements
     18from zope.interface.verify import verifyObject
    1819
    1920from twisted.trial import unittest
    2021from twisted.mail import smtp
     
    5152
    5253from twisted.test.proto_helpers import LineSendingProtocol
    5354
     55from twisted.mail.relaymanager import IQueue
    5456class DomainWithDefaultsTestCase(unittest.TestCase):
    5557    def testMethods(self):
    5658        d = dict([(x, x + 10) for x in range(10)])
     
    10021004                ['header', i]
    10031005            )
    10041006
     1007    def test_queueInterface(self):
     1008        """
     1009        Verify that L{Queue} implements L{IQueue}.
     1010        """
     1011        self.assertTrue(verifyObject(IQueue, self.queue))
     1012
    10051013from twisted.names import server
    10061014from twisted.names import client
    10071015from twisted.names import common