summaryrefslogtreecommitdiff
path: root/mailman/queue/docs
diff options
context:
space:
mode:
authorBarry Warsaw2009-01-16 21:04:21 -0500
committerBarry Warsaw2009-01-16 21:04:21 -0500
commitae3d0cc316b826b8325507d960ccf84da601c3b0 (patch)
tree3485e2ca463c2131a0ffb1693bc60d569cc9d8b7 /mailman/queue/docs
parenta3f7d07c62b2f7d6ac9d0b700883826c2838db60 (diff)
downloadmailman-ae3d0cc316b826b8325507d960ccf84da601c3b0.tar.gz
mailman-ae3d0cc316b826b8325507d960ccf84da601c3b0.tar.zst
mailman-ae3d0cc316b826b8325507d960ccf84da601c3b0.zip
Several important cleanups.
* Turn on absolute_import and unicode_literals everywhere, and deal with the aftermath. * Use 'except X as Y' everywhere. * Make the module prologues much more consistent. * Use '{}'.format() consistently, except for logger interface. * Because of the problems with calling ** args with unicode keywords, hide calls to Template.substitute() behind an API.
Diffstat (limited to 'mailman/queue/docs')
-rw-r--r--mailman/queue/docs/runner.txt12
-rw-r--r--mailman/queue/docs/switchboard.txt55
2 files changed, 37 insertions, 30 deletions
diff --git a/mailman/queue/docs/runner.txt b/mailman/queue/docs/runner.txt
index db493110c..d24a8334c 100644
--- a/mailman/queue/docs/runner.txt
+++ b/mailman/queue/docs/runner.txt
@@ -61,10 +61,12 @@ on instance variables.
<BLANKLINE>
A test message.
<BLANKLINE>
- >>> sorted(runner.msgdata.items())
- [('_parsemsg', False),
- ('bar', 'no'), ('foo', 'yes'),
- ('lang', u'en'), ('listname', u'_xtest@example.com'),
- ('received_time', ...), ('version', 3)]
+ >>> dump_msgdata(runner.msgdata)
+ _parsemsg: False
+ bar : no
+ foo : yes
+ lang : en
+ listname : _xtest@example.com
+ version : 3
XXX More of the Runner API should be tested.
diff --git a/mailman/queue/docs/switchboard.txt b/mailman/queue/docs/switchboard.txt
index 741d435e1..88ab6ea93 100644
--- a/mailman/queue/docs/switchboard.txt
+++ b/mailman/queue/docs/switchboard.txt
@@ -29,7 +29,10 @@ Here's a helper function for ensuring things work correctly.
... for qfile in os.listdir(directory):
... root, ext = os.path.splitext(qfile)
... files[ext] = files.get(ext, 0) + 1
- ... return sorted(files.items())
+ ... if len(files) == 0:
+ ... print 'empty'
+ ... for ext in sorted(files):
+ ... print '{0}: {1}'.format(ext, files[ext])
Enqueing and dequeing
@@ -40,7 +43,7 @@ dictionary.
>>> filebase = switchboard.enqueue(msg)
>>> check_qfiles()
- [('.pck', 1)]
+ .pck: 1
To read the contents of a queue file, dequeue it.
@@ -51,17 +54,18 @@ To read the contents of a queue file, dequeue it.
<BLANKLINE>
A test message.
<BLANKLINE>
- >>> sorted(msgdata.items())
- [('_parsemsg', False), ('received_time', ...), ('version', 3)]
+ >>> dump_msgdata(msgdata)
+ _parsemsg: False
+ version : 3
>>> check_qfiles()
- [('.bak', 1)]
+ .bak: 1
To complete the dequeing process, removing all traces of the message file,
finish it (without preservation).
>>> switchboard.finish(filebase)
>>> check_qfiles()
- []
+ empty
When enqueing a file, you can provide additional metadata keys by using
keyword arguments.
@@ -69,20 +73,21 @@ keyword arguments.
>>> filebase = switchboard.enqueue(msg, {'foo': 1}, bar=2)
>>> msg, msgdata = switchboard.dequeue(filebase)
>>> switchboard.finish(filebase)
- >>> sorted(msgdata.items())
- [('_parsemsg', False),
- ('bar', 2), ('foo', 1),
- ('received_time', ...), ('version', 3)]
+ >>> dump_msgdata(msgdata)
+ _parsemsg: False
+ bar : 2
+ foo : 1
+ version : 3
Keyword arguments override keys from the metadata dictionary.
>>> filebase = switchboard.enqueue(msg, {'foo': 1}, foo=2)
>>> msg, msgdata = switchboard.dequeue(filebase)
>>> switchboard.finish(filebase)
- >>> sorted(msgdata.items())
- [('_parsemsg', False),
- ('foo', 2),
- ('received_time', ...), ('version', 3)]
+ >>> dump_msgdata(msgdata)
+ _parsemsg: False
+ foo : 2
+ version : 3
Iterating over files
@@ -99,7 +104,7 @@ iterate over just these files is to use the .files attribute.
>>> sorted(switchboard.files) == filebases
True
>>> check_qfiles()
- [('.pck', 3)]
+ .pck: 3
You can also use the .get_files() method if you want to iterate over all the
file bases for some other extension.
@@ -110,11 +115,11 @@ file bases for some other extension.
>>> bakfiles == filebases
True
>>> check_qfiles()
- [('.bak', 3)]
+ .bak: 3
>>> for filebase in switchboard.get_files('.bak'):
... switchboard.finish(filebase)
>>> check_qfiles()
- []
+ empty
Recovering files
@@ -130,10 +135,10 @@ place. These can be recovered when the switchboard is instantiated.
... msg, msgdata = switchboard.dequeue(filebase)
... # Don't call .finish()
>>> check_qfiles()
- [('.bak', 3)]
+ .bak: 3
>>> switchboard_2 = Switchboard(queue_directory, recover=True)
>>> check_qfiles()
- [('.pck', 3)]
+ .pck: 3
The files can be recovered explicitly.
@@ -141,10 +146,10 @@ The files can be recovered explicitly.
... msg, msgdata = switchboard.dequeue(filebase)
... # Don't call .finish()
>>> check_qfiles()
- [('.bak', 3)]
+ .bak: 3
>>> switchboard.recover_backup_files()
>>> check_qfiles()
- [('.pck', 3)]
+ .pck: 3
But the files will only be recovered at most three times before they are
considered defective. In order to prevent mail bombs and loops, once this
@@ -154,21 +159,21 @@ maximum is reached, the files will be preserved in the 'bad' queue.
... msg, msgdata = switchboard.dequeue(filebase)
... # Don't call .finish()
>>> check_qfiles()
- [('.bak', 3)]
+ .bak: 3
>>> switchboard.recover_backup_files()
>>> check_qfiles()
- []
+ empty
>>> bad = config.switchboards['bad']
>>> check_qfiles(bad.queue_directory)
- [('.psv', 3)]
+ .psv: 3
Clean up
>>> for file in os.listdir(bad.queue_directory):
... os.remove(os.path.join(bad.queue_directory, file))
>>> check_qfiles(bad.queue_directory)
- []
+ empty
Queue slices