Skip to content

Commit 26100c0

Browse files
author
Richard Jones
committed
[SF#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 suspect 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.
1 parent a78ff9c commit 26100c0

File tree

5 files changed

+80
-58
lines changed

5 files changed

+80
-58
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Fixed:
1111
. missed a "from i18n import _" in date.py
1212
. #501690 ] MIGRATION.txt incomplete
1313
. #502342 ] pipe interface
14+
. #502437 ] rogue reactor and unittest
1415

1516
2002-01-08 - 0.4.0b1
1617
Feature:

roundup/cgi_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.96 2002-01-10 05:26:10 richard Exp $
18+
# $Id: cgi_client.py,v 1.97 2002-01-11 23:22:29 richard Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -424,7 +424,7 @@ def _createnode(self):
424424
return cl.create(**props)
425425

426426
def _handle_message(self):
427-
''' generate and edit message
427+
''' generate an edit message
428428
'''
429429
# handle file attachments
430430
files = []
@@ -1178,6 +1178,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
11781178

11791179
#
11801180
# $Log: not supported by cvs2svn $
1181+
# Revision 1.96 2002/01/10 05:26:10 richard
1182+
# missed a parsePropsFromForm in last update
1183+
#
11811184
# Revision 1.95 2002/01/10 03:39:45 richard
11821185
# . fixed some problems with web editing and change detection
11831186
#

roundup/templates/classic/detectors/nosyreaction.py

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.9 2001-12-15 19:24:39 rochecompaan Exp $
18+
#$Id: nosyreaction.py,v 1.10 2002-01-11 23:22:29 richard Exp $
1919

2020
from roundup import roundupdb
2121

@@ -61,39 +61,19 @@ def nosyreaction(db, cl, nodeid, oldvalues):
6161
except roundupdb.MessageSendError, message:
6262
raise roundupdb.DetectorError, message
6363

64-
# update the nosy list with the recipients from the new messages
65-
nosy = cl.get(nodeid, 'nosy')
66-
n = {}
67-
for nosyid in nosy: n[nosyid] = 1
68-
change = 0
69-
# but don't add admin or the anonymous user to the nosy list and
70-
# don't add the author if he just removed himself
71-
for msgid in messages:
72-
authid = db.msg.get(msgid, 'author')
73-
for recipid in db.msg.get(msgid, 'recipients'):
74-
if recipid == '1': continue
75-
if n.has_key(recipid): continue
76-
if db.user.get(recipid, 'username') == 'anonymous': continue
77-
if recipid == authid and not n.has_key(authid): continue
78-
change = 1
79-
nosy.append(recipid)
80-
if authid == '1': continue
81-
if n.has_key(authid): continue
82-
if db.user.get(authid, 'username') == 'anonymous': continue
83-
change = 1
84-
# append the author only after issue creation
85-
if oldvalues is None:
86-
nosy.append(authid)
87-
if change:
88-
cl.set(nodeid, nosy=nosy)
89-
90-
9164
def init(db):
9265
db.issue.react('create', nosyreaction)
9366
db.issue.react('set', nosyreaction)
9467

9568
#
9669
#$Log: not supported by cvs2svn $
70+
#Revision 1.9 2001/12/15 19:24:39 rochecompaan
71+
# . Modified cgi interface to change properties only once all changes are
72+
# collected, files created and messages generated.
73+
# . Moved generation of change note to nosyreactors.
74+
# . We now check for changes to "assignedto" to ensure it's added to the
75+
# nosy list.
76+
#
9777
#Revision 1.8 2001/12/05 14:26:44 rochecompaan
9878
#Removed generation of change note from "sendmessage" in roundupdb.py.
9979
#The change note is now generated when the message is created.

roundup/templates/extended/detectors/nosyreaction.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.9 2001-12-15 19:24:39 rochecompaan Exp $
18+
#$Id: nosyreaction.py,v 1.10 2002-01-11 23:22:29 richard Exp $
1919

2020
from roundup import roundupdb
2121

@@ -61,39 +61,20 @@ def nosyreaction(db, cl, nodeid, oldvalues):
6161
except roundupdb.MessageSendError, message:
6262
raise roundupdb.DetectorError, message
6363

64-
# update the nosy list with the recipients from the new messages
65-
nosy = cl.get(nodeid, 'nosy')
66-
n = {}
67-
for nosyid in nosy: n[nosyid] = 1
68-
change = 0
69-
# but don't add admin or the anonymous user to the nosy list and
70-
# don't add the author if he just removed himself
71-
for msgid in messages:
72-
authid = db.msg.get(msgid, 'author')
73-
for recipid in db.msg.get(msgid, 'recipients'):
74-
if recipid == '1': continue
75-
if n.has_key(recipid): continue
76-
if db.user.get(recipid, 'username') == 'anonymous': continue
77-
if recipid == authid and not n.has_key(authid): continue
78-
change = 1
79-
nosy.append(recipid)
80-
if authid == '1': continue
81-
if n.has_key(authid): continue
82-
if db.user.get(authid, 'username') == 'anonymous': continue
83-
change = 1
84-
# append the author only after issue creation
85-
if oldvalues is None:
86-
nosy.append(authid)
87-
if change:
88-
cl.set(nodeid, nosy=nosy)
89-
9064

9165
def init(db):
9266
db.issue.react('create', nosyreaction)
9367
db.issue.react('set', nosyreaction)
9468

9569
#
9670
#$Log: not supported by cvs2svn $
71+
#Revision 1.9 2001/12/15 19:24:39 rochecompaan
72+
# . Modified cgi interface to change properties only once all changes are
73+
# collected, files created and messages generated.
74+
# . Moved generation of change note to nosyreactors.
75+
# . We now check for changes to "assignedto" to ensure it's added to the
76+
# nosy list.
77+
#
9778
#Revision 1.8 2001/12/05 14:26:44 rochecompaan
9879
#Removed generation of change note from "sendmessage" in roundupdb.py.
9980
#The change note is now generated when the message is created.

test/test_mailgw.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_mailgw.py,v 1.1 2002-01-02 02:31:38 richard Exp $
11+
# $Id: test_mailgw.py,v 1.2 2002-01-11 23:22:29 richard Exp $
1212

1313
import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys
1414

@@ -33,6 +33,8 @@ def setUp(self):
3333
self.db = self.instance.open('sekrit')
3434
self.db.user.create(username='Chef', address='[email protected]')
3535
self.db.user.create(username='richard', address='richard@test')
36+
self.db.user.create(username='mary', address='mary@test')
37+
self.db.user.create(username='john', address='john@test')
3638

3739
def tearDown(self):
3840
if os.path.exists(os.environ['SENDMAILDEBUG']):
@@ -129,6 +131,46 @@ def testFollowup(self):
129131
130132
This is a followup
131133
134+
___________________________________________________
135+
"Roundup issue tracker" <[email protected].>
136+
http://some.useful.url/issue1
137+
___________________________________________________
138+
''', 'Generated message not correct')
139+
140+
def testFollowup2(self):
141+
self.testNewIssue()
142+
message = cStringIO.StringIO('''Content-Type: text/plain;
143+
charset="iso-8859-1"
144+
From: mary <mary@test>
145+
146+
Message-Id: <followup_dummy_id>
147+
In-Reply-To: <dummy_test_message_id>
148+
Subject: [issue1] Testing...
149+
150+
This is a second followup
151+
''')
152+
handler = self.instance.MailGW(self.instance, self.db)
153+
# TODO: fix the damn config - this is apalling
154+
handler.main(message)
155+
fname = 'fw2_%s.output'%self.count
156+
open(fname,"w").write(open(os.environ['SENDMAILDEBUG']).read())
157+
self.assertEqual(open(os.environ['SENDMAILDEBUG']).read(),
158+
159+
TO: [email protected], richard@test
160+
Content-Type: text/plain
161+
Subject: [issue1] Testing...
162+
To: [email protected], richard@test
163+
From: mary <[email protected].>
164+
Reply-To: Roundup issue tracker <[email protected].>
165+
MIME-Version: 1.0
166+
Message-Id: <followup_dummy_id>
167+
In-Reply-To: <dummy_test_message_id>
168+
169+
170+
mary <mary@test> added the comment:
171+
172+
This is a second followup
173+
132174
___________________________________________________
133175
"Roundup issue tracker" <[email protected].>
134176
http://some.useful.url/issue1
@@ -146,6 +188,21 @@ def suite():
146188

147189
#
148190
# $Log: not supported by cvs2svn $
191+
# Revision 1.1 2002/01/02 02:31:38 richard
192+
# Sorry for the huge checkin message - I was only intending to implement #496356
193+
# but I found a number of places where things had been broken by transactions:
194+
# . modified ROUNDUPDBSENDMAILDEBUG to be SENDMAILDEBUG and hold a filename
195+
# for _all_ roundup-generated smtp messages to be sent to.
196+
# . the transaction cache had broken the roundupdb.Class set() reactors
197+
# . newly-created author users in the mailgw weren't being committed to the db
198+
#
199+
# Stuff that made it into CHANGES.txt (ie. the stuff I was actually working
200+
# on when I found that stuff :):
201+
# . #496356 ] Use threading in messages
202+
# . detectors were being registered multiple times
203+
# . added tests for mailgw
204+
# . much better attaching of erroneous messages in the mail gateway
205+
#
149206
#
150207
#
151208
#

0 commit comments

Comments
 (0)