Skip to content

Commit e20397d

Browse files
author
Richard Jones
committed
fix nosyreaction.py to stop it setting the nosy list unnecessarily
1 parent dbaa78c commit e20397d

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ are given with the most recent entry first.
55
Fixed:
66
- fix reference to The Zope Book in Roundup FAQ
77
- disabled file logging in Roundup test suite (sf bug 1155649)
8+
- return original string if message issue xref isn't valid
9+
- fix nosyreaction.py to stop it setting the nosy list unnecessarily
810

911

1012
2005-03-03 0.8.2

roundup/cgi/templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ def _hyper_repl(self, match):
11461146
# make sure s1 is a valid tracker classname
11471147
cl = self._db.getclass(s1)
11481148
if not cl.hasnode(s2):
1149-
raise KeyError, 'oops'
1149+
return s
11501150
return '<a href="%s%s">%s</a>'%(s1, s2, s)
11511151
except KeyError:
11521152
return s

templates/classic/detectors/nosyreaction.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.2 2003-09-04 00:47:01 richard Exp $
18+
#$Id: nosyreaction.py,v 1.2.4.1 2005-04-04 07:16:03 richard Exp $
19+
20+
import sets
1921

2022
from roundup import roundupdb, hyperdb
2123

@@ -65,7 +67,7 @@ def updatenosy(db, cl, nodeid, newvalues):
6567
'''Update the nosy list for changes to the assignedto
6668
'''
6769
# nodeid will be None if this is a new node
68-
current = {}
70+
current_nosy = sets.Set()
6971
if nodeid is None:
7072
ok = ('new', 'yes')
7173
else:
@@ -75,17 +77,17 @@ def updatenosy(db, cl, nodeid, newvalues):
7577
if not newvalues.has_key('nosy'):
7678
nosy = cl.get(nodeid, 'nosy')
7779
for value in nosy:
78-
if not current.has_key(value):
79-
current[value] = 1
80+
current_nosy.add(value)
8081

8182
# if the nosy list changed in this transaction, init from the new value
8283
if newvalues.has_key('nosy'):
8384
nosy = newvalues.get('nosy', [])
8485
for value in nosy:
8586
if not db.hasnode('user', value):
8687
continue
87-
if not current.has_key(value):
88-
current[value] = 1
88+
current_nosy.add(value)
89+
90+
new_nosy = sets.Set(current_nosy)
8991

9092
# add assignedto(s) to the nosy list
9193
if newvalues.has_key('assignedto') and newvalues['assignedto'] is not None:
@@ -95,8 +97,7 @@ def updatenosy(db, cl, nodeid, newvalues):
9597
elif isinstance(propdef['assignedto'], hyperdb.Multilink):
9698
assignedto_ids = newvalues['assignedto']
9799
for assignedto_id in assignedto_ids:
98-
if not current.has_key(assignedto_id):
99-
current[assignedto_id] = 1
100+
new_nosy.add(assignedto_id)
100101

101102
# see if there's any new messages - if so, possibly add the author and
102103
# recipient to the nosy
@@ -107,7 +108,6 @@ def updatenosy(db, cl, nodeid, newvalues):
107108
else:
108109
ok = ('yes',)
109110
# figure which of the messages now on the issue weren't
110-
# there before
111111
oldmessages = cl.get(nodeid, 'messages')
112112
messages = []
113113
for msgid in newvalues['messages']:
@@ -123,15 +123,16 @@ def updatenosy(db, cl, nodeid, newvalues):
123123
for msgid in messages:
124124
if add_author in ok:
125125
authid = msg.get(msgid, 'author')
126-
current[authid] = 1
126+
new_nosy.add(authid)
127127

128128
# add on the recipients of the message
129129
if add_recips in ok:
130130
for recipient in msg.get(msgid, 'recipients'):
131-
current[recipient] = 1
131+
new_nosy.add(recipient)
132132

133-
# that's it, save off the new nosy list
134-
newvalues['nosy'] = current.keys()
133+
if current_nosy != new_nosy:
134+
# that's it, save off the new nosy list
135+
newvalues['nosy'] = list(new_nosy)
135136

136137
def init(db):
137138
db.issue.react('create', nosyreaction)
@@ -140,3 +141,4 @@ def init(db):
140141
db.issue.audit('set', updatenosy)
141142

142143
# vim: set filetype=python ts=4 sw=4 et si
144+
#SHA: 509a13c8501bbdf8d171ddab4e91c4ff0b9da957

0 commit comments

Comments
 (0)