add sequencial number in subject prefix

Bug #557972 reported by tkikuchi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Mailman
Fix Released
High
Unassigned

Bug Description

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.

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

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

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

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.

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

update for 2.1b6+

Revision history for this message
fabiorossetti (fabiorossetti) wrote :

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']

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

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

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

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

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

sorry for daily update but there was an error in i18n
handling of '(no subject)'

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

The file CookHeaders.py.diff211.txt was added: patch for mailman-2.1.1 rev 030227

Revision history for this message
jojoba2 (jojoba2) wrote :

Logged In: YES
user_id=718482

Is there a version vor MM 2.1.2? I'm trying the older one but
doesn't seem to work.

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

Here is update of my patch for 2.1.2

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

The file CookHeaders.py.patch.txt was added: for 2.1.2

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

Now the patch includes instruction in General admin page.
(in detail part). In source dir you should type:
patch -p0 < /path/to/seqnum.patch

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

The file seqnum.patch was added: patch for 2.1.3 includes instructions

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

This patch for 2.1.3 is also applicable to 2.1.4. Though one
patch fails to apply, it can safely be neglected. You can
also get a newer and more convenient patch at:
 http://mm.tkikuchi.net/mailman-2.1.4+patch.20040123.gz

Cheers,
TK

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

You can download the patch for 2.1.5 from
 http://mm.tkikuchi.net/mailman-2.1.5+patch.20040516.gz

TK

Revision history for this message
shobhanc (shobhanc-users) wrote :

Logged In: YES
user_id=598275

Hi tkikuchi,

There are some gibberish text within the patch, are they
Japanesh chars..??

If possible can you look at this tracker and give your
suggestions.https://sourceforge.net/tracker/index.php?func=detail&aid=1024289&group_id=103&atid=300103

This is basically I want to implement threading in Mailman.
Yes Mailman implements threading I agree but when the mail
replies are sent using Lotus Notes 5.0.8/5.0.9 the threading
doesn't work because Lotus Notes doesn't set the
"In-Reply-To" header.

Thanks for your time

Revision history for this message
tkikuchi (tkikuchi-users) wrote :

Logged In: YES
user_id=67709

Merged in CVS.
Checking in Gui/General.py;
new revision: 2.22.2.3; previous revision: 2.22.2.2
Checking in Handlers/CookHeaders.py;
new revision: 2.33.2.7; previous revision: 2.33.2.6

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.