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
2022from 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
136137def 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