diff options
| author | Sandesh Kumar Agrawal | 2013-01-17 05:24:32 +0530 |
|---|---|---|
| committer | Sandesh Kumar Agrawal | 2013-01-17 05:24:32 +0530 |
| commit | 5ffa4a1323c9e4f75334d2792b8a5f66d4e6f6f0 (patch) | |
| tree | d489bc8724434a2994d866c4e7f77c883bfe45e5 /src | |
| parent | c6dd23a544a552995fa4e0e22b8ae5c9dd8544c4 (diff) | |
| download | mailman-5ffa4a1323c9e4f75334d2792b8a5f66d4e6f6f0.tar.gz mailman-5ffa4a1323c9e4f75334d2792b8a5f66d4e6f6f0.tar.zst mailman-5ffa4a1323c9e4f75334d2792b8a5f66d4e6f6f0.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/config/mailman.cfg | 2 | ||||
| -rw-r--r-- | src/mailman/core/runner.py | 11 | ||||
| -rw-r--r-- | src/mailman/core/switchboard.py | 19 | ||||
| -rw-r--r-- | src/mailman/interfaces/runner.py | 4 | ||||
| -rw-r--r-- | src/mailman/rest/tests/test_root.py | 7 | ||||
| -rw-r--r-- | src/mailman/runners/lmtp.py | 6 | ||||
| -rw-r--r-- | src/mailman/runners/rest.py | 1 | ||||
| -rw-r--r-- | src/mailman/runners/tests/test_lmtp.py | 7 |
8 files changed, 40 insertions, 17 deletions
diff --git a/src/mailman/config/mailman.cfg b/src/mailman/config/mailman.cfg index 80725b15f..00831df46 100644 --- a/src/mailman/config/mailman.cfg +++ b/src/mailman/config/mailman.cfg @@ -60,6 +60,7 @@ class: mailman.runners.incoming.IncomingRunner [runner.lmtp] class: mailman.runners.lmtp.LMTPRunner +path: [runner.nntp] class: mailman.runners.nntp.NNTPRunner @@ -72,6 +73,7 @@ class: mailman.runners.pipeline.PipelineRunner [runner.rest] class: mailman.runners.rest.RESTRunner +path: [runner.retry] class: mailman.runners.retry.RetryRunner diff --git a/src/mailman/core/runner.py b/src/mailman/core/runner.py index f088e29bb..05a70ce5b 100644 --- a/src/mailman/core/runner.py +++ b/src/mailman/core/runner.py @@ -52,6 +52,7 @@ elog = logging.getLogger('mailman.error') @implementer(IRunner) class Runner: intercept_signals = True + is_non_queue_runner = False def __init__(self, name, slice=None): """Create a runner. @@ -68,8 +69,14 @@ class Runner: substitutions['name'] = name self.queue_directory = expand(section.path, substitutions) numslices = int(section.instances) - self.switchboard = Switchboard( - name, self.queue_directory, slice, numslices, True) + # Check whether the runner is queue runner or not; non queue runner should not have queue_directory or switchboard instance. + if self.is_non_queue_runner: + self.queue_directory = None + self.switchboard= None + else: + self.queue_directory = expand(section.path, substitutions) + self.switchboard = Switchboard( + name, self.queue_directory, slice, numslices, True) self.sleep_time = as_timedelta(section.sleep_time) # sleep_time is a timedelta; turn it into a float for time.sleep(). self.sleep_float = (86400 * self.sleep_time.days + diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py index e2df550ca..61e0e5334 100644 --- a/src/mailman/core/switchboard.py +++ b/src/mailman/core/switchboard.py @@ -93,14 +93,7 @@ class Switchboard: self.non_queue_runner={'lmtp','rest'} # If configured to, create the directory if it doesn't yet exist. if config.create_paths: - for directory in self.queue_directory.split(): - is_non_queue_runner=False - for queue in self.non_queue_runner: - if queue in directory: - is_non_queue_runner=True - break - if not(is_non_queue_runner): - makedirs(directory,0770) + makedirs(self.queue_directory,0770) # Fast track for no slices self._lower = None self._upper = None @@ -274,7 +267,9 @@ def handle_ConfigurationUpdatedEvent(event): name = conf.name.split('.')[-1] assert name not in config.switchboards, ( 'Duplicate runner name: {0}'.format(name)) - substitutions = config.paths - substitutions['name'] = name - path = expand(conf.path, substitutions) - config.switchboards[name] = Switchboard(name, path) + # Path is empty for non queue runners. hence check for path and create switchboard instance only for queu runner. + if conf.path: + substitutions = config.paths + substitutions['name'] = name + path = expand(conf.path, substitutions) + config.switchboards[name] = Switchboard(name, path) diff --git a/src/mailman/interfaces/runner.py b/src/mailman/interfaces/runner.py index 0c8c53f92..39948592d 100644 --- a/src/mailman/interfaces/runner.py +++ b/src/mailman/interfaces/runner.py @@ -50,6 +50,10 @@ class IRunner(Interface): def stop(): """Stop the runner on the next iteration through the loop.""" + + is_non_queue_runner = Attribute("""\ + A boolean variable to keep track of whether the runner is a queue runner or not. + """) queue_directory = Attribute( 'The queue directory. Overridden in subclasses.') diff --git a/src/mailman/rest/tests/test_root.py b/src/mailman/rest/tests/test_root.py index 0f75b14b8..6e08ce1f5 100644 --- a/src/mailman/rest/tests/test_root.py +++ b/src/mailman/rest/tests/test_root.py @@ -25,9 +25,11 @@ __all__ = [ import unittest +import os from urllib2 import HTTPError +from mailman.config import config from mailman.testing.helpers import call_api from mailman.testing.layers import RESTLayer @@ -67,3 +69,8 @@ class TestSystem(unittest.TestCase): 'receive_own_postings': True, }, method='PUT') self.assertEqual(cm.exception.code, 405) + + def test_rest_queue_directory(self): + # Rest is a non queue runner, so it should not have a directory in var/queue + is_directory = os.path.isdir(os.path.join(config.paths['QUEUE_DIR'],'rest')) + self.assertEqual(is_directory,False) diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py index 0a51c534e..cd9538829 100644 --- a/src/mailman/runners/lmtp.py +++ b/src/mailman/runners/lmtp.py @@ -98,7 +98,6 @@ ERR_501 = b'501 Message has defects' ERR_502 = b'502 Error: command HELO not implemented' ERR_550 = b'550 Requested action not taken: mailbox unavailable' ERR_550_MID = b'550 No Message-ID header provided' -ERR_DUP = b'Duplicate Message ID' # XXX Blech smtpd.__version__ = b'Python LMTP runner 1.0' @@ -155,6 +154,9 @@ class LMTPRunner(Runner, smtpd.SMTPServer): # Only __init__ is called on startup. Asyncore is responsible for later # connections from the MTA. slice and numslices are ignored and are # necessary only to satisfy the API. + + is_non_queue_runner = True + def __init__(self, slice=None, numslices=1): localaddr = config.mta.lmtp_host, int(config.mta.lmtp_port) # Do not call Runner's constructor because there's no QDIR to create @@ -188,8 +190,6 @@ class LMTPRunner(Runner, smtpd.SMTPServer): return ERR_550_MID if msg.defects: return ERR_501 - if message_store.get_message_by_id(message_id): - return ERR_DUP msg.original_size = len(data) add_message_hash(msg) msg['X-MailFrom'] = mailfrom diff --git a/src/mailman/runners/rest.py b/src/mailman/runners/rest.py index 8c6a210e1..e6a851bb7 100644 --- a/src/mailman/runners/rest.py +++ b/src/mailman/runners/rest.py @@ -41,6 +41,7 @@ log = logging.getLogger('mailman.http') class RESTRunner(Runner): intercept_signals = False + is_non_queue_runner = True def run(self): log.info('Starting REST server') diff --git a/src/mailman/runners/tests/test_lmtp.py b/src/mailman/runners/tests/test_lmtp.py index 3e31a1f5e..f58125eb8 100644 --- a/src/mailman/runners/tests/test_lmtp.py +++ b/src/mailman/runners/tests/test_lmtp.py @@ -27,9 +27,11 @@ __all__ = [ import smtplib import unittest +import os from datetime import datetime +from mailman.config import config from mailman.app.lifecycle import create_list from mailman.database.transaction import transaction from mailman.testing.helpers import get_lmtp_client, get_queue_messages @@ -109,3 +111,8 @@ Message-ID: <ant> self.assertEqual(len(messages), 1) self.assertEqual(messages[0].msgdata['received_time'], datetime(2005, 8, 1, 7, 49, 23)) + + def test_lmtp_queue_directory(self): + # Lmtp is a non queue runner, so it should not have a directory in var/queue + is_directory = os.path.isdir(os.path.join(config.paths['QUEUE_DIR'],'lmtp')) + self.assertEqual(is_directory,False) |
