summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mailman/commands/docs/inject.rst2
-rw-r--r--src/mailman/config/mailman.cfg2
-rw-r--r--src/mailman/core/runner.py13
-rw-r--r--src/mailman/core/switchboard.py11
-rw-r--r--src/mailman/docs/NEWS.rst5
-rw-r--r--src/mailman/interfaces/runner.py4
-rw-r--r--src/mailman/rest/tests/test_root.py9
-rw-r--r--src/mailman/runners/lmtp.py3
-rw-r--r--src/mailman/runners/rest.py1
-rw-r--r--src/mailman/runners/tests/test_lmtp.py8
10 files changed, 49 insertions, 9 deletions
diff --git a/src/mailman/commands/docs/inject.rst b/src/mailman/commands/docs/inject.rst
index e8987128c..5d07e0458 100644
--- a/src/mailman/commands/docs/inject.rst
+++ b/src/mailman/commands/docs/inject.rst
@@ -34,11 +34,9 @@ It's easy to find out which queues are available.
command
digest
in
- lmtp
nntp
out
pipeline
- rest
retry
shunt
virgin
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..a8412195d 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_queue_runner = True
def __init__(self, name, slice=None):
"""Create a runner.
@@ -66,10 +67,16 @@ class Runner:
section = getattr(config, 'runner.' + name)
substitutions = config.paths
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_queue_runner:
+ self.queue_directory = expand(section.path, substitutions)
+ self.switchboard = Switchboard(
+ name, self.queue_directory, slice, numslices, True)
+ else:
+ self.queue_directory = None
+ self.switchboard= None
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 f0c7bff5e..ec0231ed7 100644
--- a/src/mailman/core/switchboard.py
+++ b/src/mailman/core/switchboard.py
@@ -266,7 +266,10 @@ 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. Check for path and create
+ # switchboard instances only for queue runners.
+ 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/docs/NEWS.rst b/src/mailman/docs/NEWS.rst
index b2e643fe7..fcf9a26c0 100644
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -12,6 +12,11 @@ Here is a history of user visible changes to Mailman.
===============================
(2013-XX-XX)
+Bugs
+----
+ * Non-queue runners should not create ``var/queue`` subdirectories. Fixed by
+ Sandesh Kumar Agrawal. (LP: #1095422)
+
3.0 beta 3 -- "Here Again"
==========================
diff --git a/src/mailman/interfaces/runner.py b/src/mailman/interfaces/runner.py
index 0c8c53f92..1dfe7e266 100644
--- a/src/mailman/interfaces/runner.py
+++ b/src/mailman/interfaces/runner.py
@@ -51,6 +51,10 @@ class IRunner(Interface):
def stop():
"""Stop the runner on the next iteration through the loop."""
+ is_queue_runner = Attribute("""\
+ A boolean variable describing whether the runner is a queue runner.
+ """)
+
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..4cf12da30 100644
--- a/src/mailman/rest/tests/test_root.py
+++ b/src/mailman/rest/tests/test_root.py
@@ -21,13 +21,16 @@ from __future__ import absolute_import, unicode_literals
__metaclass__ = type
__all__ = [
+ 'TestSystem',
]
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 +70,9 @@ class TestSystem(unittest.TestCase):
'receive_own_postings': True,
}, method='PUT')
self.assertEqual(cm.exception.code, 405)
+
+ def test_queue_directory(self):
+ # The REST runner is not queue runner, so it should not have a
+ # directory in var/queue.
+ queue_directory = os.path.join(config.QUEUE_DIR, 'rest')
+ self.assertFalse(os.path.isdir(queue_directory))
diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py
index e967f8965..31d7723f5 100644
--- a/src/mailman/runners/lmtp.py
+++ b/src/mailman/runners/lmtp.py
@@ -153,6 +153,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_queue_runner = False
+
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
diff --git a/src/mailman/runners/rest.py b/src/mailman/runners/rest.py
index 8c6a210e1..468d9a95c 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_queue_runner = False
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 41ac5b7cf..a5c2105d9 100644
--- a/src/mailman/runners/tests/test_lmtp.py
+++ b/src/mailman/runners/tests/test_lmtp.py
@@ -25,11 +25,13 @@ __all__ = [
]
+import os
import smtplib
import unittest
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,9 @@ Message-ID: <ant>
self.assertEqual(len(messages), 1)
self.assertEqual(messages[0].msgdata['received_time'],
datetime(2005, 8, 1, 7, 49, 23))
+
+ def test_queue_directory(self):
+ # The LMTP runner is not queue runner, so it should not have a
+ # directory in var/queue.
+ queue_directory = os.path.join(config.QUEUE_DIR, 'lmtp')
+ self.assertFalse(os.path.isdir(queue_directory))