diff options
| author | Barry Warsaw | 2012-04-22 16:40:34 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2012-04-22 16:40:34 -0400 |
| commit | 3ffddba89c0a0c66280a90b6643d9a66632a5b74 (patch) | |
| tree | 6a222e2eb6ab2a19bdcbdc968f3bf58a8f2846fc /src/mailman/commands/cli_lists.py | |
| parent | aa12d1c5a4544e7005a6a93e2fff6e130b30e8b6 (diff) | |
| download | mailman-3ffddba89c0a0c66280a90b6643d9a66632a5b74.tar.gz mailman-3ffddba89c0a0c66280a90b6643d9a66632a5b74.tar.zst mailman-3ffddba89c0a0c66280a90b6643d9a66632a5b74.zip | |
Diffstat (limited to 'src/mailman/commands/cli_lists.py')
| -rw-r--r-- | src/mailman/commands/cli_lists.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/mailman/commands/cli_lists.py b/src/mailman/commands/cli_lists.py index af6afe22d..17d4bc375 100644 --- a/src/mailman/commands/cli_lists.py +++ b/src/mailman/commands/cli_lists.py @@ -17,7 +17,7 @@ """The 'lists' subcommand.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -31,9 +31,9 @@ from zope.component import getUtility from zope.interface import implements from mailman.app.lifecycle import create_list, remove_list -from mailman.config import config from mailman.core.constants import system_preferences from mailman.core.i18n import _ +from mailman.database.transaction import transaction, transactional from mailman.email.message import UserNotification from mailman.interfaces.address import ( IEmailValidator, InvalidEmailAddressError) @@ -98,11 +98,11 @@ class Lists: # Maybe no mailing lists matched. if len(mailing_lists) == 0: if not args.quiet: - print _('No matching mailing lists found') + print(_('No matching mailing lists found')) return count = len(mailing_lists) if not args.quiet: - print _('$count matching mailing lists found:') + print(_('$count matching mailing lists found:')) # Calculate the longest identifier. longest = 0 output = [] @@ -120,8 +120,8 @@ class Lists: else: format_string = '{0:{2}}' for identifier, description in output: - print format_string.format( - identifier, description, longest, 70 - longest) + print(format_string.format( + identifier, description, longest, 70 - longest)) @@ -214,13 +214,13 @@ class Create: self.parser.error(_('Undefined domain: $domain')) return # Find the language associated with the code, then set the mailing - # list's preferred language to that. The changes then must be - # committed to the database. - mlist.preferred_language = getUtility(ILanguageManager)[language_code] - config.db.commit() + # list's preferred language to that. + language_manager = getUtility(ILanguageManager) + with transaction(): + mlist.preferred_language = language_manager[language_code] # Do the notification. if not args.quiet: - print _('Created mailing list: $mlist.fqdn_listname') + print(_('Created mailing list: $mlist.fqdn_listname')) if args.notify: d = dict( listname = mlist.fqdn_listname, @@ -262,11 +262,12 @@ class Remove: The 'fully qualified list name', i.e. the posting address of the mailing list.""")) + @transactional def process(self, args): """See `ICLISubCommand`.""" def log(message): if not args.quiet: - print message + print(message) assert len(args.listname) == 1, ( 'Unexpected positional arguments: %s' % args.listname) fqdn_listname = args.listname[0] @@ -277,4 +278,3 @@ class Remove: else: log(_('Removed list: $fqdn_listname')) remove_list(fqdn_listname, mlist) - config.db.commit() |
