diff options
Diffstat (limited to 'src/mailman/core/pipelines.py')
| -rw-r--r-- | src/mailman/core/pipelines.py | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/src/mailman/core/pipelines.py b/src/mailman/core/pipelines.py index bd709f41e..25bb68030 100644 --- a/src/mailman/core/pipelines.py +++ b/src/mailman/core/pipelines.py @@ -15,12 +15,16 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. -"""Pipeline processor.""" +"""Built-in pipelines.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ + 'BasePipeline', + 'OwnerPipeline', + 'PostingPipeline', + 'VirginPipeline', 'initialize', 'process', ] @@ -31,13 +35,16 @@ import logging from zope.interface import implements from zope.interface.verify import verifyObject +from mailman.app.bounces import bounce_message from mailman.app.finder import find_components from mailman.config import config +from mailman.core import errors from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler from mailman.interfaces.pipeline import IPipeline -log = logging.getLogger('mailman.debug') +dlog = logging.getLogger('mailman.debug') +vlog = logging.getLogger('mailman.vette') @@ -52,9 +59,19 @@ def process(mlist, msg, msgdata, pipeline_name='built-in'): message_id = msg.get('message-id', 'n/a') pipeline = config.pipelines[pipeline_name] for handler in pipeline: - log.debug('[pipeline] processing {0}: {1}'.format( - handler.name, message_id)) - handler.process(mlist, msg, msgdata) + dlog.debug('{0} pipeline {1} processing: {2}'.format( + message_id, pipeline_name, handler.name)) + try: + handler.process(mlist, msg, msgdata) + except errors.DiscardMessage as error: + vlog.info( + '{0} discarded by "{1}" pipeline handler "{2}": {3}'.format( + message_id, pipeline_name, handler.name, error.message)) + except errors.RejectMessage as error: + vlog.info( + '{0} rejected by "{1}" pipeline handler "{2}": {3}'.format( + message_id, pipeline_name, handler.name, error.message)) + bounce_message(mlist, msg, error) @@ -76,24 +93,36 @@ class BasePipeline: yield handler -class BuiltInPipeline(BasePipeline): - """The built-in pipeline.""" + +class OwnerPipeline(BasePipeline): + """The built-in owner pipeline.""" + + name = 'default-owner-pipeline' + description = _('The built-in owner pipeline.') + + _default_handlers = ( + 'owner-recipients', + 'to-outgoing', + ) + + +class PostingPipeline(BasePipeline): + """The built-in posting pipeline.""" name = 'default-posting-pipeline' - description = _('The built-in pipeline.') + description = _('The built-in posting pipeline.') _default_handlers = ( 'mime-delete', - 'scrubber', 'tagger', - 'calculate-recipients', + 'member-recipients', 'avoid-duplicates', 'cleanse', 'cleanse-dkim', 'cook-headers', 'rfc-2369', - 'to-digest', 'to-archive', + 'to-digest', 'to-usenet', 'after-delivery', 'acknowledge', @@ -119,7 +148,7 @@ class VirginPipeline(BasePipeline): def initialize(): """Initialize the pipelines.""" # Find all handlers in the registered plugins. - for handler_class in find_components('mailman.pipeline', IHandler): + for handler_class in find_components('mailman.handlers', IHandler): handler = handler_class() verifyObject(IHandler, handler) assert handler.name not in config.handlers, ( @@ -127,6 +156,6 @@ def initialize(): handler.name, handler_class)) config.handlers[handler.name] = handler # Set up some pipelines. - for pipeline_class in (BuiltInPipeline, VirginPipeline): + for pipeline_class in (OwnerPipeline, PostingPipeline, VirginPipeline): pipeline = pipeline_class() config.pipelines[pipeline.name] = pipeline |
