diff options
| author | Barry Warsaw | 2011-06-10 19:52:25 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2011-06-10 19:52:25 -0400 |
| commit | f8596ce463863dc6defb5dac84f5b226c45cb419 (patch) | |
| tree | 616e2f0d952d1654d3b0b60d661f5349d469acf4 /src/mailman/commands/docs | |
| parent | bf8b285acb8c2500e52ae2582f27513b9842de54 (diff) | |
| download | mailman-f8596ce463863dc6defb5dac84f5b226c45cb419.tar.gz mailman-f8596ce463863dc6defb5dac84f5b226c45cb419.tar.zst mailman-f8596ce463863dc6defb5dac84f5b226c45cb419.zip | |
Refactor MTA alias creation.
* Create an IMailTransportAgentAliases utility that contains all the logic for
generating all the aliases for a mailing list, both the fully-qualified ones
and the local-part ones.
* Add -f and -s options to `bin/mailman aliases` to facilitate outputing the
aliases in other formats than the configured one, and for printing out a
simple list of the aliases.
* IMailTransportAgentAliases -> IMailTransportAgentLifecycle; also add a new
definition for IMailTransportAgentAliases
Diffstat (limited to 'src/mailman/commands/docs')
| -rw-r--r-- | src/mailman/commands/docs/aliases.rst (renamed from src/mailman/commands/docs/aliases.txt) | 74 |
1 files changed, 61 insertions, 13 deletions
diff --git a/src/mailman/commands/docs/aliases.txt b/src/mailman/commands/docs/aliases.rst index 0822ad973..c0d4c10c9 100644 --- a/src/mailman/commands/docs/aliases.txt +++ b/src/mailman/commands/docs/aliases.rst @@ -6,11 +6,12 @@ For some mail servers, Mailman must generate a data file that is used to hook Mailman up to the mail server. The details of this differ for each mail server. Generally these files are automatically kept up-to-date when mailing lists are created or removed, but you might occasionally need to manually -regenerate the file. The 'bin/mailman aliases' command does this. +regenerate the file. The ``bin/mailman aliases`` command does this. >>> class FakeArgs: ... output = None - + ... format = None + ... simple = None >>> from mailman.commands.cli_aliases import Aliases >>> command = Aliases() @@ -32,19 +33,13 @@ generation. Let's create a mailing list and then display the transport map for it. We'll send the output to stdout. +:: >>> FakeArgs.output = '-' >>> mlist = create_list('test@example.com') >>> command.process(FakeArgs) # AUTOMATICALLY GENERATED BY MAILMAN ON ... - # - # This file is generated by Mailman, and is kept in sync with the ... - # file. YOU SHOULD NOT MANUALLY EDIT THIS FILE unless you know what you're - # doing, and can keep the two files properly in sync. If you screw it up, - # you're on your own. - <BLANKLINE> - # Aliases which are visible only in the @example.com domain. - <BLANKLINE> + ... test@example.com lmtp:[lmtp.example.com]:24 test-bounces@example.com lmtp:[lmtp.example.com]:24 test-confirm@example.com lmtp:[lmtp.example.com]:24 @@ -56,8 +51,61 @@ send the output to stdout. test-unsubscribe@example.com lmtp:[lmtp.example.com]:24 <BLANKLINE> + >>> config.pop('postfix') -Clean up -======== - >>> config.pop('postfix') +Alternative output +================== + +By using a command line switch, we can select a different output format. The +option must point to an alternative implementation of the +``IMailTransportAgentAliases`` interface. + +Mailman comes with an alternative implementation that just prints the aliases, +with no adornment. + + >>> FakeArgs.format = 'mailman.commands.cli_aliases.Dummy' + >>> command.process(FakeArgs) + test@example.com + test-bounces@example.com + test-confirm@example.com + test-join@example.com + test-leave@example.com + test-owner@example.com + test-request@example.com + test-subscribe@example.com + test-unsubscribe@example.com + <BLANKLINE> + +A simpler way of getting the same output is with the ``--simple`` flag. + + >>> FakeArgs.format = None + >>> FakeArgs.simple = True + >>> command.process(FakeArgs) + test@example.com + test-bounces@example.com + test-confirm@example.com + test-join@example.com + test-leave@example.com + test-owner@example.com + test-request@example.com + test-subscribe@example.com + test-unsubscribe@example.com + <BLANKLINE> + + +Mutually exclusive arguments +============================ + +You cannot use both ``--simple`` and ``--format``. + + >>> FakeArgs.format = 'mailman.commands.cli_aliases.Dummy' + >>> FakeArgs.simple = True + >>> class Parser: + ... def error(self, message): + ... raise RuntimeError(message) + >>> command.parser = Parser() + >>> command.process(FakeArgs) + Traceback (most recent call last): + ... + RuntimeError: Cannot use both -s and -f |
