summaryrefslogtreecommitdiff
path: root/src/mailman/handlers
diff options
context:
space:
mode:
authorBarry Warsaw2012-03-31 04:51:42 -0600
committerBarry Warsaw2012-03-31 04:51:42 -0600
commitf11b1601c61c97a3fc2dd400fbc2913235efa83d (patch)
tree5b3ef89bbc99cf17b7dabbc48026c1f585eead29 /src/mailman/handlers
parent7f0c57ca63d13058934e3eb8423ea52075e984ae (diff)
downloadmailman-f11b1601c61c97a3fc2dd400fbc2913235efa83d.tar.gz
mailman-f11b1601c61c97a3fc2dd400fbc2913235efa83d.tar.zst
mailman-f11b1601c61c97a3fc2dd400fbc2913235efa83d.zip
* The `news` runner and queue has been renamed to the more accurate `nntp`.
Beta testers can can safely remove `$var_dir/queue/news`.
Diffstat (limited to 'src/mailman/handlers')
-rw-r--r--src/mailman/handlers/cook_headers.py2
-rw-r--r--src/mailman/handlers/docs/nntp.rst35
-rw-r--r--src/mailman/handlers/docs/subject-munging.rst10
-rw-r--r--src/mailman/handlers/to_usenet.py13
4 files changed, 29 insertions, 31 deletions
diff --git a/src/mailman/handlers/cook_headers.py b/src/mailman/handlers/cook_headers.py
index 2d117429c..5d1e416a6 100644
--- a/src/mailman/handlers/cook_headers.py
+++ b/src/mailman/handlers/cook_headers.py
@@ -190,7 +190,7 @@ def prefix_subject(mlist, msg, msgdata):
ws = '\t'
if len(lines) > 1 and lines[1] and lines[1][0] in ' \t':
ws = lines[1][0]
- msgdata['origsubj'] = subject
+ msgdata['original_subject'] = subject
# The subject may be multilingual but we take the first charset as major
# one and try to decode. If it is decodable, returned subject is in one
# line and cset is properly set. If fail, subject is mime-encoded and
diff --git a/src/mailman/handlers/docs/nntp.rst b/src/mailman/handlers/docs/nntp.rst
index 874712397..c298fcb14 100644
--- a/src/mailman/handlers/docs/nntp.rst
+++ b/src/mailman/handlers/docs/nntp.rst
@@ -3,15 +3,14 @@ NNTP Gateway
============
Mailman has an NNTP gateway, whereby messages posted to the mailing list can
-be forwarded onto an NNTP newsgroup. Typically this means Usenet, but since
-NNTP is to Usenet as IP is to the web, it's more general than that.
+be forwarded onto an NNTP newsgroup.
- >>> mlist = create_list('_xtest@example.com')
+ >>> mlist = create_list('test@example.com')
Gatewaying from the mailing list to the newsgroup happens through a separate
``nntp`` queue and happen immediately when the message is posted through to
the list. Note that gatewaying from the newsgroup to the list happens via a
-cronjob (currently not shown).
+separate process.
There are several situations which prevent a message from being gatewayed to
the newsgroup. The feature could be disabled, as is the default.
@@ -26,43 +25,43 @@ the newsgroup. The feature could be disabled, as is the default.
>>> handler = config.handlers['to-usenet']
>>> handler.process(mlist, msg, {})
-
- >>> switchboard = config.switchboards['news']
- >>> switchboard.files
+ >>> from mailman.testing.helpers import get_queue_messages
+ >>> get_queue_messages('nntp')
[]
Even if enabled, messages that came from the newsgroup are never gated back to
the newsgroup.
>>> mlist.gateway_to_news = True
- >>> handler.process(mlist, msg, {'fromusenet': True})
- >>> switchboard.files
+ >>> handler.process(mlist, msg, dict(fromusenet=True))
+ >>> get_queue_messages('nntp')
[]
Neither are digests ever gated to the newsgroup.
- >>> handler.process(mlist, msg, {'isdigest': True})
- >>> switchboard.files
+ >>> handler.process(mlist, msg, dict(isdigest=True))
+ >>> get_queue_messages('nntp')
[]
However, other posted messages get gated to the newsgroup via the nntp queue.
The list owner can set the linked newsgroup and the nntp host that its
messages are gated to.
+::
>>> mlist.linked_newsgroup = 'comp.lang.thing'
>>> mlist.nntp_host = 'news.example.com'
>>> handler.process(mlist, msg, {})
- >>> len(switchboard.files)
+ >>> messages = get_queue_messages('nntp')
+ >>> len(messages)
1
- >>> filebase = switchboard.files[0]
- >>> msg, msgdata = switchboard.dequeue(filebase)
- >>> switchboard.finish(filebase)
- >>> print msg.as_string()
+
+ >>> print messages[0].msg.as_string()
Subject: An important message
<BLANKLINE>
Something of great import.
<BLANKLINE>
- >>> dump_msgdata(msgdata)
+
+ >>> dump_msgdata(messages[0].msgdata)
_parsemsg: False
- listname : _xtest@example.com
+ listname : test@example.com
version : 3
diff --git a/src/mailman/handlers/docs/subject-munging.rst b/src/mailman/handlers/docs/subject-munging.rst
index 48cee8e2b..f9e3b9abb 100644
--- a/src/mailman/handlers/docs/subject-munging.rst
+++ b/src/mailman/handlers/docs/subject-munging.rst
@@ -8,7 +8,7 @@ transformations. Some headers get added, others get changed. Some of these
changes depend on mailing list settings and others depend on how the message
is getting sent through the system. We'll take things one-by-one.
- >>> mlist = create_list('_xtest@example.com')
+ >>> mlist = create_list('test@example.com')
Inserting a prefix
@@ -32,11 +32,9 @@ subject munging, a mailing list must have a preferred language.
>>> from mailman.handlers.cook_headers import process
>>> process(mlist, msg, msgdata)
-The original subject header is stored in the message metadata. We must print
-the new ``Subject`` header because it gets converted from a string to an
-``email.header.Header`` instance which has an unhelpful ``repr``.
+The original subject header is stored in the message metadata.
- >>> msgdata['origsubj']
+ >>> msgdata['original_subject']
u''
>>> print msg['subject']
[XTest] (no subject)
@@ -52,7 +50,7 @@ at the beginning of the header's value.
... """)
>>> msgdata = {}
>>> process(mlist, msg, msgdata)
- >>> print msgdata['origsubj']
+ >>> print msgdata['original_subject']
Something important
>>> print msg['subject']
[XTest] Something important
diff --git a/src/mailman/handlers/to_usenet.py b/src/mailman/handlers/to_usenet.py
index 26a383c64..021f8f9e5 100644
--- a/src/mailman/handlers/to_usenet.py
+++ b/src/mailman/handlers/to_usenet.py
@@ -17,7 +17,7 @@
"""Move the message to the mail->news queue."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -50,11 +50,12 @@ class ToUsenet:
def process(self, mlist, msg, msgdata):
"""See `IHandler`."""
# Short circuits.
- if not mlist.gateway_to_news or \
- msgdata.get('isdigest') or \
- msgdata.get('fromusenet'):
+ if (not mlist.gateway_to_news or
+ msgdata.get('isdigest') or
+ msgdata.get('fromusenet')):
+ # Short-circuit.
return
- # sanity checks
+ # Sanity checks.
error = []
if not mlist.linked_newsgroup:
error.append('no newsgroup')
@@ -65,5 +66,5 @@ class ToUsenet:
COMMASPACE.join(error))
return
# Put the message in the news runner's queue.
- config.switchboards['news'].enqueue(
+ config.switchboards['nntp'].enqueue(
msg, msgdata, listname=mlist.fqdn_listname)