From 0bb6049d6be7684411169bc2aa01a35ed44858cf Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 11 Jan 2002 23:22:29 +0000 Subject: [PATCH] . #502437 ] rogue reactor and unittest in short, the nosy reactor was modifying the nosy list. That code had been there for a long time, and I suspsect it was there because we weren't generating the nosy list correctly in other places of the code. We're now doing that, so the nosy-modifying code can go away from the nosy reactor. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@534 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + roundup/cgi_client.py | 7 ++- .../classic/detectors/nosyreaction.py | 36 +++-------- .../extended/detectors/nosyreaction.py | 35 +++-------- test/test_mailgw.py | 59 ++++++++++++++++++- 5 files changed, 80 insertions(+), 58 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 02a98e9..4179e81 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,7 @@ Fixed: . missed a "from i18n import _" in date.py . #501690 ] MIGRATION.txt incomplete . #502342 ] pipe interface + . #502437 ] rogue reactor and unittest 2002-01-08 - 0.4.0b1 Feature: diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index 2fef807..d53b02d 100644 --- a/roundup/cgi_client.py +++ b/roundup/cgi_client.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: cgi_client.py,v 1.96 2002-01-10 05:26:10 richard Exp $ +# $Id: cgi_client.py,v 1.97 2002-01-11 23:22:29 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -424,7 +424,7 @@ class Client: return cl.create(**props) def _handle_message(self): - ''' generate and edit message + ''' generate an edit message ''' # handle file attachments files = [] @@ -1178,6 +1178,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0): # # $Log: not supported by cvs2svn $ +# Revision 1.96 2002/01/10 05:26:10 richard +# missed a parsePropsFromForm in last update +# # Revision 1.95 2002/01/10 03:39:45 richard # . fixed some problems with web editing and change detection # diff --git a/roundup/templates/classic/detectors/nosyreaction.py b/roundup/templates/classic/detectors/nosyreaction.py index 1088aa0..46099e2 100644 --- a/roundup/templates/classic/detectors/nosyreaction.py +++ b/roundup/templates/classic/detectors/nosyreaction.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: nosyreaction.py,v 1.9 2001-12-15 19:24:39 rochecompaan Exp $ +#$Id: nosyreaction.py,v 1.10 2002-01-11 23:22:29 richard Exp $ from roundup import roundupdb @@ -61,39 +61,19 @@ def nosyreaction(db, cl, nodeid, oldvalues): except roundupdb.MessageSendError, message: raise roundupdb.DetectorError, message - # update the nosy list with the recipients from the new messages - nosy = cl.get(nodeid, 'nosy') - n = {} - for nosyid in nosy: n[nosyid] = 1 - change = 0 - # but don't add admin or the anonymous user to the nosy list and - # don't add the author if he just removed himself - for msgid in messages: - authid = db.msg.get(msgid, 'author') - for recipid in db.msg.get(msgid, 'recipients'): - if recipid == '1': continue - if n.has_key(recipid): continue - if db.user.get(recipid, 'username') == 'anonymous': continue - if recipid == authid and not n.has_key(authid): continue - change = 1 - nosy.append(recipid) - if authid == '1': continue - if n.has_key(authid): continue - if db.user.get(authid, 'username') == 'anonymous': continue - change = 1 - # append the author only after issue creation - if oldvalues is None: - nosy.append(authid) - if change: - cl.set(nodeid, nosy=nosy) - - def init(db): db.issue.react('create', nosyreaction) db.issue.react('set', nosyreaction) # #$Log: not supported by cvs2svn $ +#Revision 1.9 2001/12/15 19:24:39 rochecompaan +# . Modified cgi interface to change properties only once all changes are +# collected, files created and messages generated. +# . Moved generation of change note to nosyreactors. +# . We now check for changes to "assignedto" to ensure it's added to the +# nosy list. +# #Revision 1.8 2001/12/05 14:26:44 rochecompaan #Removed generation of change note from "sendmessage" in roundupdb.py. #The change note is now generated when the message is created. diff --git a/roundup/templates/extended/detectors/nosyreaction.py b/roundup/templates/extended/detectors/nosyreaction.py index 6dfe243..d148b41 100644 --- a/roundup/templates/extended/detectors/nosyreaction.py +++ b/roundup/templates/extended/detectors/nosyreaction.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: nosyreaction.py,v 1.9 2001-12-15 19:24:39 rochecompaan Exp $ +#$Id: nosyreaction.py,v 1.10 2002-01-11 23:22:29 richard Exp $ from roundup import roundupdb @@ -61,32 +61,6 @@ def nosyreaction(db, cl, nodeid, oldvalues): except roundupdb.MessageSendError, message: raise roundupdb.DetectorError, message - # update the nosy list with the recipients from the new messages - nosy = cl.get(nodeid, 'nosy') - n = {} - for nosyid in nosy: n[nosyid] = 1 - change = 0 - # but don't add admin or the anonymous user to the nosy list and - # don't add the author if he just removed himself - for msgid in messages: - authid = db.msg.get(msgid, 'author') - for recipid in db.msg.get(msgid, 'recipients'): - if recipid == '1': continue - if n.has_key(recipid): continue - if db.user.get(recipid, 'username') == 'anonymous': continue - if recipid == authid and not n.has_key(authid): continue - change = 1 - nosy.append(recipid) - if authid == '1': continue - if n.has_key(authid): continue - if db.user.get(authid, 'username') == 'anonymous': continue - change = 1 - # append the author only after issue creation - if oldvalues is None: - nosy.append(authid) - if change: - cl.set(nodeid, nosy=nosy) - def init(db): db.issue.react('create', nosyreaction) @@ -94,6 +68,13 @@ def init(db): # #$Log: not supported by cvs2svn $ +#Revision 1.9 2001/12/15 19:24:39 rochecompaan +# . Modified cgi interface to change properties only once all changes are +# collected, files created and messages generated. +# . Moved generation of change note to nosyreactors. +# . We now check for changes to "assignedto" to ensure it's added to the +# nosy list. +# #Revision 1.8 2001/12/05 14:26:44 rochecompaan #Removed generation of change note from "sendmessage" in roundupdb.py. #The change note is now generated when the message is created. diff --git a/test/test_mailgw.py b/test/test_mailgw.py index 12dbfe2..3d353d7 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.1 2002-01-02 02:31:38 richard Exp $ +# $Id: test_mailgw.py,v 1.2 2002-01-11 23:22:29 richard Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys @@ -33,6 +33,8 @@ class MailgwTestCase(unittest.TestCase): self.db = self.instance.open('sekrit') self.db.user.create(username='Chef', address='chef@bork.bork.bork') self.db.user.create(username='richard', address='richard@test') + self.db.user.create(username='mary', address='mary@test') + self.db.user.create(username='john', address='john@test') def tearDown(self): if os.path.exists(os.environ['SENDMAILDEBUG']): @@ -129,6 +131,46 @@ richard added the comment: This is a followup +___________________________________________________ +"Roundup issue tracker" +http://some.useful.url/issue1 +___________________________________________________ +''', 'Generated message not correct') + + def testFollowup2(self): + self.testNewIssue() + message = cStringIO.StringIO('''Content-Type: text/plain; + charset="iso-8859-1" +From: mary +To: issue_tracker@fill.me.in. +Message-Id: +In-Reply-To: +Subject: [issue1] Testing... + +This is a second followup +''') + handler = self.instance.MailGW(self.instance, self.db) + # TODO: fix the damn config - this is apalling + handler.main(message) + fname = 'fw2_%s.output'%self.count + open(fname,"w").write(open(os.environ['SENDMAILDEBUG']).read()) + self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(), +'''FROM: roundup-admin@fill.me.in. +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 +MIME-Version: 1.0 +Message-Id: +In-Reply-To: + + +mary added the comment: + +This is a second followup + ___________________________________________________ "Roundup issue tracker" http://some.useful.url/issue1 @@ -146,6 +188,21 @@ def suite(): # # $Log: not supported by cvs2svn $ +# Revision 1.1 2002/01/02 02:31:38 richard +# Sorry for the huge checkin message - I was only intending to implement #496356 +# but I found a number of places where things had been broken by transactions: +# . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename +# for _all_ roundup-generated smtp messages to be sent to. +# . the transaction cache had broken the roundupdb.Class set() reactors +# . newly-created author users in the mailgw weren't being committed to the db +# +# Stuff that made it into CHANGES.txt (ie. the stuff I was actually working +# on when I found that stuff :): +# . #496356 ] Use threading in messages +# . detectors were being registered multiple times +# . added tests for mailgw +# . much better attaching of erroneous messages in the mail gateway +# # # # -- 2.30.2