From 698d8fa4b7163ae782c67973000fa2f6d303807d Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 5 Nov 2002 22:59:46 +0000 Subject: [PATCH] - updated email package address formatting (deprecation) - copied email address quoting from email v2.4.3 so we're consistent with 2.2 - email summary extraction now takes the first whole sentence or line - whichever is longer git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1373 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 4 + TODO.txt | 5 +- doc/customizing.txt | 6 +- doc/index.txt | 2 + roundup/mailgw.py | 21 +++-- roundup/roundupdb.py | 16 +++- roundup/scripts/roundup_server.py | 3 +- test/test_mailgw.py | 143 +++++++++++++++--------------- 8 files changed, 114 insertions(+), 86 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 4c9d42c..2d29c38 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,10 @@ are given with the most recent entry first. - force non-word boundary to match re: in subject (sf bug 626303) - handle sqlite bug (<2.7.2) (sf bug 630828) - handle missing props in anydbm stringFind +- updated email package address formatting (deprecation) +- copied email address quoting from email v2.4.3 so we're consistent with 2.2 +- email summary extraction now takes the first whole sentence or line - + whichever is longer 2002-10-16 0.5.1 diff --git a/TODO.txt b/TODO.txt index dbe7c13..e37e0a6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -15,6 +15,7 @@ pending hyperdb range searching of values (dates in particular). comparison functions: lt, le, eq, ge, gt. eq and [value, value, ...] implies "in" pending hyperdb migrate "id" property to be Number type +pending hyperdb multilink sorting by length is dumb pending tracker split instance.open() into open() and login() pending mailgw allow commands (feature request #556996) like "help", "dump issue123" (would send all info about @@ -61,10 +62,8 @@ pending web search "refinement" - pre-fill the search page with the pending web column-heading sort stuff isn't implemented active web UNIX init.d script for roundup-server -bug docs need to mention somewhere how sorting works - - it's mentioned in the design doc - - multilink sorting by length is dumb bug web query editing isn't fully implemented bug web no testing for parsePropsFromForm +active web revert to showing entire message in classic issue display ======= ========= ============================================================= diff --git a/doc/customizing.txt b/doc/customizing.txt index b75388b..60ec721 100644 --- a/doc/customizing.txt +++ b/doc/customizing.txt @@ -2,7 +2,7 @@ Customising Roundup =================== -:Version: $Revision: 1.60 $ +:Version: $Revision: 1.61 $ .. This document borrows from the ZopeBook section on ZPT. The original is at: http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx @@ -2582,7 +2582,7 @@ able to give a summary of the total time spent on a particular issue. Using a UN*X passwd file as the user database --------------------------------------------- -On some systems, the primary store of users is the UN*X passwd file. It holds +On some systems the primary store of users is the UN*X passwd file. It holds information on users such as their username, real name, password and primary user group. @@ -2600,9 +2600,11 @@ day, or several times an hour if more immediate access is needed. In short, it: 1. parses the passwd file, finding usernames, passwords and real names, 2. compares that list to the current roundup user list: + a. entries no longer in the passwd file are *retired* b. entries with mismatching real names are *updated* c. entries only exist in the passwd file are *created* + 3. send an email to administrators to let them know what's been done. The retiring and updating are simple operations, requiring only a call to diff --git a/doc/index.txt b/doc/index.txt index 7973569..731d58e 100644 --- a/doc/index.txt +++ b/doc/index.txt @@ -65,6 +65,7 @@ project and those who just report bugs: Anthony Baxter, Jeff Blaine, Duncan Booth, +Seb Brezel, Titus Brown, Roch'e Compaan, Engelbert Gruber, @@ -74,6 +75,7 @@ James Kew, Detlef Lannert, Gordon McMillan, Patrick Ohly, +Will Partain, Bernhard Reiter, Dougal Scott, Stefan Seefeld, diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 3aa50b9..8b4f95e 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.98 2002-10-21 22:03:09 richard Exp $ +$Id: mailgw.py,v 1.99 2002-11-05 22:59:46 richard Exp $ ''' import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri @@ -913,17 +913,16 @@ def parseContent(content, keep_citations, keep_body, l.append(section) continue # keep this section - it has reponse stuff in it - if not summary: - # and while we're at it, use the first non-quoted bit as - # our summary - summary = line lines = lines[lines.index(line):] section = '\n'.join(lines) + # and while we're at it, use the first non-quoted bit as + # our summary + summary = section if not summary: # if we don't have our summary yet use the first line of this # section - summary = lines[0] + summary = section elif signature.match(lines[0]) and 2 <= len(lines) <= 10: # lose any signature break @@ -934,6 +933,16 @@ def parseContent(content, keep_citations, keep_body, # and add the section to the output l.append(section) + # figure the summary - find the first sentence-ending punctuation or the + # first whole line, whichever is longest + sentence = re.search(r'^([^!?\.]+[!?\.])', summary) + if sentence: + sentence = sentence.group(1) + else: + sentence = '' + first = eol.split(summary)[0] + summary = max(sentence, first) + # Now reconstitute the message content minus the bits we don't care # about. if not keep_body: diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index e94632b..8fd9b28 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundupdb.py,v 1.72 2002-10-08 07:28:34 richard Exp $ +# $Id: roundupdb.py,v 1.73 2002-11-05 22:59:46 richard Exp $ __doc__ = """ Extending hyperdb with types specific to issue-tracking. @@ -26,9 +26,19 @@ import MimeWriter, cStringIO import base64, quopri, mimetypes # if available, use the 'email' module, otherwise fallback to 'rfc822' try : - from email.Utils import dump_address_pair as straddr + from email.Utils import formataddr as straddr except ImportError : - from rfc822 import dump_address_pair as straddr + # code taken from the email package 2.4.3 + def straddr(pair, specialsre = re.compile(r'[][\()<>@,:;".]'), + escapesre = re.compile(r'[][\()"]')): + name, address = pair + if name: + quotes = '' + if specialsre.search(name): + quotes = '"' + name = escapesre.sub(r'\\\g<0>', name) + return '%s%s%s <%s>' % (quotes, name, quotes, address) + return address import hyperdb diff --git a/roundup/scripts/roundup_server.py b/roundup/scripts/roundup_server.py index 4f4b213..aa09755 100644 --- a/roundup/scripts/roundup_server.py +++ b/roundup/scripts/roundup_server.py @@ -16,7 +16,7 @@ # """ HTTP Server that serves roundup. -$Id: roundup_server.py,v 1.14 2002-10-08 03:31:09 richard Exp $ +$Id: roundup_server.py,v 1.15 2002-11-05 22:59:46 richard Exp $ """ # python version check @@ -158,6 +158,7 @@ class RoundupRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = ', '.join(co) + env['HTTP_AUTHORIZATION'] = self.headers.getheader('authorization') env['SCRIPT_NAME'] = '' env['SERVER_NAME'] = self.server.server_name env['SERVER_PORT'] = str(self.server.server_port) diff --git a/test/test_mailgw.py b/test/test_mailgw.py index af81ce6..f8332b6 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.32 2002-09-26 03:04:24 richard Exp $ +# $Id: test_mailgw.py,v 1.33 2002-11-05 22:59:46 richard Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib @@ -81,13 +81,14 @@ class MailgwTestCase(unittest.TestCase, DiffHelper): # and open the database self.db = self.instance.open('admin') self.db.user.create(username='Chef', address='chef@bork.bork.bork', - roles='User') + realname='Bork, Chef', roles='User') self.db.user.create(username='richard', address='richard@test', roles='User') self.db.user.create(username='mary', address='mary@test', - roles='User') + roles='User', realname='Contrary, Mary') self.db.user.create(username='john', address='john@test', - alternate_addresses='jondoe@test\njohn.doe@test', roles='User') + alternate_addresses='jondoe@test\njohn.doe@test', roles='User', + realname='John Doe') def tearDown(self): if os.path.exists(os.environ['SENDMAILDEBUG']): @@ -204,15 +205,15 @@ TO: chef@bork.bork.bork, mary@test, richard@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, mary@test, richard@test -From: "Chef" -Reply-To: "Roundup issue tracker" +From: "Bork, Chef" +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: X-Roundup-Name: Roundup issue tracker Content-Transfer-Encoding: quoted-printable -New submission from Chef : +New submission from Bork, Chef : This is a test submission of a new issue. @@ -223,10 +224,10 @@ messages: 1 nosy: Chef, mary, richard status: unread title: Testing... -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') # BUG @@ -259,8 +260,8 @@ TO: chef@bork.bork.bork, richard@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, richard@test -From: "mary" -Reply-To: "Roundup issue tracker" +From: "Contrary, Mary" +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -268,17 +269,17 @@ X-Roundup-Name: Roundup issue tracker Content-Transfer-Encoding: quoted-printable -mary added the comment: +Contrary, Mary added the comment: This is a second followup ---------- status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') def testFollowup(self): @@ -307,8 +308,8 @@ TO: chef@bork.bork.bork, john@test, mary@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, john@test, mary@test -From: "richard" -Reply-To: "Roundup issue tracker" +From: richard +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -325,10 +326,10 @@ This is a followup assignedto: -> mary nosy: +john, mary status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') def testFollowupTitleMatch(self): @@ -353,8 +354,8 @@ TO: chef@bork.bork.bork, john@test, mary@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, john@test, mary@test -From: "richard" -Reply-To: "Roundup issue tracker" +From: richard +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -371,10 +372,10 @@ This is a followup assignedto: -> mary nosy: +john, mary status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') def testFollowupNosyAuthor(self): @@ -400,8 +401,8 @@ TO: chef@bork.bork.bork, richard@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, richard@test -From: "john" -Reply-To: "Roundup issue tracker" +From: John Doe +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -409,7 +410,7 @@ X-Roundup-Name: Roundup issue tracker Content-Transfer-Encoding: quoted-printable -john added the comment: +John Doe added the comment: This is a followup @@ -417,10 +418,10 @@ This is a followup ---------- nosy: +john status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') @@ -448,8 +449,8 @@ TO: chef@bork.bork.bork Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork -From: "richard" -Reply-To: "Roundup issue tracker" +From: richard +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -465,10 +466,10 @@ This is a followup ---------- nosy: +john status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') @@ -496,8 +497,8 @@ TO: chef@bork.bork.bork, john@test, richard@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, john@test, richard@test -From: "john" -Reply-To: "Roundup issue tracker" +From: John Doe +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -505,7 +506,7 @@ X-Roundup-Name: Roundup issue tracker Content-Transfer-Encoding: quoted-printable -john added the comment: +John Doe added the comment: This is a followup @@ -513,10 +514,10 @@ This is a followup ---------- nosy: +john status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') @@ -543,8 +544,8 @@ TO: chef@bork.bork.bork, richard@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, richard@test -From: "john" -Reply-To: "Roundup issue tracker" +From: John Doe +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -552,17 +553,17 @@ X-Roundup-Name: Roundup issue tracker Content-Transfer-Encoding: quoted-printable -john added the comment: +John Doe added the comment: This is a followup ---------- status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') @@ -590,8 +591,8 @@ TO: chef@bork.bork.bork Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork -From: "richard" -Reply-To: "Roundup issue tracker" +From: richard +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -606,10 +607,10 @@ This is a followup ---------- status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') @@ -698,8 +699,8 @@ TO: chef@bork.bork.bork, richard@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, richard@test -From: "mary" -Reply-To: "Roundup issue tracker" +From: "Contrary, Mary" +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -707,16 +708,16 @@ X-Roundup-Name: Roundup issue tracker Content-Transfer-Encoding: quoted-printable -mary added the comment: +Contrary, Mary added the comment: A message with encoding (encoded oe =F6) ---------- status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') @@ -752,8 +753,8 @@ TO: chef@bork.bork.bork, richard@test Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork, richard@test -From: "mary" -Reply-To: "Roundup issue tracker" +From: "Contrary, Mary" +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -761,16 +762,16 @@ X-Roundup-Name: Roundup issue tracker Content-Transfer-Encoding: quoted-printable -mary added the comment: +Contrary, Mary added the comment: A message with first part encoded (encoded oe =F6) ---------- status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') def testFollowupStupidQuoting(self): @@ -796,8 +797,8 @@ TO: chef@bork.bork.bork Content-Type: text/plain Subject: [issue1] Testing... To: chef@bork.bork.bork -From: "richard" -Reply-To: "Roundup issue tracker" +From: richard +Reply-To: Roundup issue tracker MIME-Version: 1.0 Message-Id: In-Reply-To: @@ -812,10 +813,10 @@ This is a followup ---------- status: unread -> chatting -_________________________________________________________________________ -"Roundup issue tracker" +_______________________________________________________________________ +Roundup issue tracker http://your.tracker.url.example/issue1 -_________________________________________________________________________ +_______________________________________________________________________ ''') def suite(): -- 2.30.2