[Mailman-Developers] Modifications to msg
Ellen Spertus
spertus@mills.edu
Mon, 18 Mar 2002 13:43:57 -0800
--=====================_169733023==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
I've been making some modifications to Mailman to support dynamic sublists
(http://javamlm.mills.edu). I'm still rather new with Python and have a
question about modifying fields (dictionary elements) of the msg data
structure. Specifically, I added the following code to change the
message's "To" field at the end of CookHeaders.py:
1 if msgdata.get('dlist'):
2 threadID = msgdata['thread_id']
3 syslog('info', "threadID = %d", threadID)
4 to_line = '%s-%d@%s' % (mlist.real_name.lower(),
threadID,
mlist.host_name)
5 syslog('info', "to_line = %s", to_line)
6 del msg['To']
7 msg['To'] = to_line
8 syslog('info', "Set msg['To'] to '%s'", msg['To'])
This correctly changes the "To" field of the message from
etest-new@hostname to etest-<threadID>@hostname, as shown by the log:
Mar 18 13:29:55 2002 (4600) threadID = 19
Mar 18 13:29:55 2002 (4600) to_line = etest-19@javamlm.mills.edu
Mar 18 13:29:55 2002 (4600) Set msg['To'] to 'etest-19@javamlm.mills.edu'
Similarly, the resulting email message that is sent has the new 'To' field.
The problem is I don't see why line 6 above is necessary. When I comment
it out, however, I get the incongruous logfile entry:
Mar 18 13:36:04 2002 (4640) threadID = 20
Mar 18 13:36:04 2002 (4640) to_line = etest-20@javamlm.mills.edu
Mar 18 13:36:04 2002 (4640) Set msg['To'] to 'etest-new@javamlm.mills.edu'
as though line 7 had never been executed. The final email message contains
two "To" headers, one with "etest-new" and one with
"etest-<threadID>". It's not clear to me why the original value is
preserved instead of overwritten. Could someone let me know what I'm
missing about dictionaries or the email class?
Thank you.
Ellen Spertus
--=====================_169733023==_.ALT
Content-Type: text/html; charset="us-ascii"
<html>
I've been making some modifications to Mailman to support dynamic
sublists
(<a href="http://javamlm.mills.edu/" eudora="autourl">http://javamlm.mills.edu</a>).
I'm still rather new with Python and have a question about modifying
fields (dictionary elements) of the msg data structure.
Specifically, I added the following code to change the message's
"To" field at the end of CookHeaders.py:<br><br>
1 if msgdata.get('dlist'):<br>
2 threadID =
msgdata['thread_id']<br>
3 syslog('info', "threadID
= %d", threadID)<br>
4 to_line = '%s-%d@%s' %
(mlist.real_name.lower(),<br>
threadID,<br>
mlist.host_name)<br>
5 syslog('info', "to_line
= %s", to_line)<br>
6 del msg['To']<br>
7 msg['To'] = to_line<br>
8 syslog('info', "Set
msg['To'] to '%s'", msg['To'])<br><br>
This correctly changes the "To" field of the message from
etest-new@hostname to etest-<threadID>@hostname, as shown by the
log:<br>
<dl>
<dd>Mar 18 13:29:55 2002 (4600) threadID = 19
<dd>Mar 18 13:29:55 2002 (4600) to_line = etest-19@javamlm.mills.edu
<dd>Mar 18 13:29:55 2002 (4600) Set msg['To'] to
'etest-19@javamlm.mills.edu'<br><br>
</dl>Similarly, the resulting email message that is sent has the new 'To'
field.<br><br>
The problem is I don't see why line 6 above is necessary. When I
comment it out, however, I get the incongruous logfile entry:<br>
<dl>
<dd>Mar 18 13:36:04 2002 (4640) threadID = 20
<dd>Mar 18 13:36:04 2002 (4640) to_line = etest-20@javamlm.mills.edu
<dd>Mar 18 13:36:04 2002 (4640) Set msg['To'] to
'etest-new@javamlm.mills.edu'<br><br>
</dl>as though line 7 had never been executed. The final email
message contains two "To" headers, one with
"etest-new" and one with
"etest-<threadID>". It's not clear to me why the
original value is preserved instead of overwritten. Could
someone let me know what I'm missing about dictionaries or the email
class?<br><br>
Thank you.<br><br>
Ellen Spertus<br>
</html>
--=====================_169733023==_.ALT--