[ mailman-Patches-601117 ] add sequencial number in subject prefix

SourceForge.net noreply at sourceforge.net
Tue Feb 25 17:25:15 EST 2003


Patches item #601117, was opened at 2002-08-28 05:07
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=300103&aid=601117&group_id=103

Category: mail delivery
Group: Mailman 2.2 / 3.0
Status: Open
Resolution: None
>Priority: 7
Submitted By: Tokio Kikuchi (tkikuchi)
Assigned to: Nobody/Anonymous (nobody)
Summary: add sequencial number in subject prefix

Initial Comment:
This patch for 'CookHeaders.py' add an ability to add a
sequencial number in the subject prefix. You can define
a subject prefix like:
   [listname %d]
Then, the subject line of delivered mail becomes:
   Subject: [listname 123] Hoge hoge
When someone replied this mail, mailman receives a
messages with:
   Subject: Re: [listname 123] Hoge hoge
Then, this patch removes [listname \d+] part and
deliver it with:
   Subject: [listname 124] Re: Hoge hoge
And next, another person replies with
   Subject: Re: [listname 124] Re: Hoge hoge
Then, (magically!) you get:
   Subject: [listname 125] Re: Hoge hoge
Not with Re: Re: Hoge hoge.

Looks like complicated but this patch has been working
well with Japanese-enhanced Mailman for more than a year.

Without %d, this patch works like current version, I
believe.



----------------------------------------------------------------------

>Comment By: Tokio Kikuchi (tkikuchi)
Date: 2003-02-26 01:25

Message:
Logged In: YES 
user_id=67709

update of patch for 2.1.1
if the subject is all ascii, then cat the prefix and subject
before it is instantiated. Hope to solve prefix only subject
1st line.

Note: with this patch without $d, Re: [prefix] is now
mungled to [prefix] Re:. This is useful if someone post new
issue as follow up to old subject like;
New subject bah bah was Re: [prefix] foo


----------------------------------------------------------------------

Comment By: Tokio Kikuchi (tkikuchi)
Date: 2003-02-14 11:33

Message:
Logged In: YES 
user_id=67709

Hi, I am pleased you like this patch.
Here is my current version attached.


----------------------------------------------------------------------

Comment By: Fabio Rossetti (fabiorossetti)
Date: 2003-02-14 10:02

Message:
Logged In: YES 
user_id=693899

If you need a quick fix to make the patch work with 2.1.1 
here's my take (it's the diff file adapted to work with 2.1.1 
CookHeaders.py)

17a18
>    (sequence version)
221c222,223
<     prefix = mlist.subject_prefix
---
>     prefix = mlist.subject_prefix.strip();
>     if not prefix: return
237,243c239,250
<     if prefix and subject:
<         pattern = re.escape(prefix.strip())
<         for decodedsubj, charset in headerbits:
<             if re.search(pattern, decodedsubj, 
re.IGNORECASE):
<                 # The subject's already got the prefix, so don't 
change it
<                 return
<     del msg['subject']
---
>     headerstring = ''
>     fws = ''
>     cset = None
>     for (s, c) in headerbits:
>         headerstring += fws + s
>         if c == None or c == 'us-ascii':
>             fws = ' '
>             cset = Utils.GetCharSet(mlist.preferred_language)
>         else:
>             fws = ''
>             cset = c
>     # Note: searching prefix in subject is REMOVED. (seq 
version)
245a253,275
>     else:
>         subject = headerstring
>     # If the subject_prefix contains '%d', it is replaced with 
the
>     # mailing list sequential number. Also, if the prefix is 
closed with
>     # [],(), or {}, the prefix in the responding post subject will 
be cared.
>     # sequential number format allows '%05d' like pattern.
>     p = re.compile('%\d*d')
>     if p.search(prefix,1):
>         # prefix have number, so we should search prefix 
w/number
>         # in subject.
>         prefix_pattern = p.sub(r'\s*\d+\s*', prefix)
>     else:
>         prefix_pattern = prefix
>     prefix_pattern = re.sub('([\[\(\{])', '\\\g<1>', prefix_pattern)
>     subject = re.sub(prefix_pattern, '', subject)
>     subject = re.compile('(RE:\s*)+', re.I).sub('Re: ', subject, 
1)
>     # and substitute %d in prefix with post_id
>     try:
>         prefix = prefix % mlist.post_id
>     except:
>         pass
>     # Note that trailing space was stripped in seq version 
(TK)
>     prefix += ' '
248,262c278,288
<     for s, c in headerbits:
<         # Once again, convert the string to unicode.
<         if c is None:
<             c = Charset('iso-8859-1')
<         if not isinstance(c, Charset):
<             c = Charset(c)
<         if not _isunicode(s):
<             codec = c.input_codec or 'ascii'
<             try:
<                 s = unicode(s, codec, 'replace')
<             except LookupError:
<                 # Unknown codec, is this default reasonable?
<                 s = unicode(s, Utils.GetCharSet
(mlist.preferred_language),
<                             'replace')
<         h.append(s, c)
---
>     # in seq version, subject header is already concatnated
>     if not _isunicode(subject):
>         try:
>             subject = unicode(subject, cset, 'replace')
>         except LookupError:
>             # unknown codec
>             cset = Utils.GetCharSet(mlist.preferred_language)
>             subject = unicode(subject, cset, 'replace')
>     subject = subject.encode(cset)
>     h.append(subject, cset)
>     del msg['subject']


----------------------------------------------------------------------

Comment By: Tokio Kikuchi (tkikuchi)
Date: 2002-12-20 04:31

Message:
Logged In: YES 
user_id=67709

update for 2.1b6+


----------------------------------------------------------------------

Comment By: Tokio Kikuchi (tkikuchi)
Date: 2002-10-31 05:59

Message:
Logged In: YES 
user_id=67709

I have uploaded the patch with the same name as the old one.
Please download the upper one because it's newer.
Sorry for the inconvenience.


----------------------------------------------------------------------

Comment By: Tokio Kikuchi (tkikuchi)
Date: 2002-10-31 05:53

Message:
Logged In: YES 
user_id=67709

Patch ID 625482 (i18n List-Id) and this was merged for 2.1b4+



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=300103&aid=601117&group_id=103



More information about the Mailman-coders mailing list