------------------------------------------------------------
revno: 6633
committer: Barry Warsaw <[EMAIL PROTECTED]>
branch nick: 3.0
timestamp: Sat 2008-04-26 01:57:53 -0400
message:
  Handle commands in the body of a plain text email message.
modified:
  mailman/queue/command.py
  mailman/queue/docs/command.txt

=== modified file 'mailman/queue/command.py'
--- a/mailman/queue/command.py  2008-04-26 05:39:14 +0000
+++ b/mailman/queue/command.py  2008-04-26 05:57:53 +0000
@@ -111,7 +111,10 @@
             line = self.command_lines.pop(0)
             self.processed_lines.append(line)
             parts = line.strip().split()
-            yield parts[0], tuple(parts[1:])
+            if len(parts) == 0:
+                continue
+            command = parts.pop(0)
+            yield command, tuple(parts)
 
 
 

=== modified file 'mailman/queue/docs/command.txt'
--- a/mailman/queue/docs/command.txt    2008-04-26 05:39:14 +0000
+++ b/mailman/queue/docs/command.txt    2008-04-26 05:57:53 +0000
@@ -9,6 +9,10 @@
     >>> from mailman.app.lifecycle import create_list
     >>> mlist = create_list(u'[EMAIL PROTECTED]')
 
+
+A command in the Subject
+------------------------
+
 For example, the 'echo' command simply echoes the original command back to the
 sender.  The command can be in the Subject header.
 
@@ -59,3 +63,44 @@
     [..., ('listname', u'[EMAIL PROTECTED]'), ...,
      ('recips', [u'[EMAIL PROTECTED]']),
      ...]
+
+
+A command in the body
+---------------------
+
+The command can also be found in the body of the message, as long as the
+message is plain text.
+
+    >>> msg = message_from_string("""\
+    ... From: [EMAIL PROTECTED]
+    ... To: [EMAIL PROTECTED]
+    ... Message-ID: <bobcat>
+    ...
+    ... echo foo bar
+    ... """)
+
+    >>> inject_message(mlist, msg, qdir=config.CMDQUEUE_DIR)
+    >>> command.run()
+    >>> len(virgin_queue.files)
+    1
+    >>> item = get_queue_messages(virgin_queue)[0]
+    >>> print item.msg.as_string()
+    Subject: The results of your email commands
+    From: [EMAIL PROTECTED]
+    To: [EMAIL PROTECTED]
+    ...
+    Precedence: bulk
+    <BLANKLINE>
+    The results of your email command are provided below.
+    <BLANKLINE>
+    - Original message details:
+        From: [EMAIL PROTECTED]
+        Subject: n/a
+        Date: ...
+        Message-ID: <bobcat>
+    <BLANKLINE>
+    - Results:
+    echo foo bar
+    <BLANKLINE>
+    - Done.
+    <BLANKLINE>



--
Primary development focus
https://code.launchpad.net/~mailman-coders/mailman/3.0

You are receiving this branch notification because you are subscribed to it.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to