1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: roundupdb.py,v 1.93 2003-11-06 19:01:57 jlgijsbers Exp $
18+ # $Id: roundupdb.py,v 1.94 2003-11-16 19:59:09 jlgijsbers Exp $
1919
2020__doc__ = """
2121Extending hyperdb with types specific to issue-tracking.
@@ -133,10 +133,8 @@ def nosymessage(self, nodeid, msgid, oldvalues, whichnosy='nosy',
133133 If 'msgid' is None, the message gets sent only to the nosy
134134 list, and it's called a 'System Message'.
135135 """
136- authid , recipients = None , []
137- if msgid :
138- authid = self .db .msg .get (msgid , 'author' )
139- recipients = self .db .msg .get (msgid , 'recipients' )
136+ authid = self .db .msg .safeget (msgid , 'author' )
137+ recipients = self .db .msg .safeget (msgid , 'recipients' , [])
140138
141139 sendto = []
142140 seen_message = dict ([(recipient , 1 ) for recipient in recipients ])
@@ -192,36 +190,30 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
192190 users = self .db .user
193191 messages = self .db .msg
194192 files = self .db .file
195-
196- inreplyto , messageid = None , None
197- if msgid :
198- inreplyto = messages .get (msgid , 'inreplyto' )
199- messageid = messages .get (msgid , 'messageid' )
200-
201- # make up a messageid if there isn't one (web edit)
202- if not messageid :
203- # this is an old message that didn't get a messageid, so
204- # create one
205- messageid = "<%s.%s.%s%s@%s>" % (time .time (), random .random (),
206- self .classname , nodeid ,
207- self .db .config .MAIL_DOMAIN )
208- messages .set (msgid , messageid = messageid )
193+
194+ inreplyto = messages .safeget (msgid , 'inreplyto' )
195+ messageid = messages .safeget (msgid , 'messageid' )
196+
197+ # make up a messageid if there isn't one (web edit)
198+ if not messageid :
199+ # this is an old message that didn't get a messageid, so
200+ # create one
201+ messageid = "<%s.%s.%s%s@%s>" % (time .time (), random .random (),
202+ self .classname , nodeid ,
203+ self .db .config .MAIL_DOMAIN )
204+ messages .set (msgid , messageid = messageid )
209205
210206 # send an email to the people who missed out
211207 cn = self .classname
212208 title = self .get (nodeid , 'title' ) or '%s message copy' % cn
213209
214- authid , authname , authaddr = None , '' , ''
215- if msgid :
216- authid = messages .get (msgid , 'author' )
217- authname = users .get (authid , 'realname' )
218- if not authname :
219- authname = users .get (authid , 'username' )
220- authaddr = users .get (authid , 'address' )
221- if authaddr :
222- authaddr = " <%s>" % straddr ( ('' ,authaddr ) )
223- else :
224- authaddr = ''
210+ authid = messages .safeget (msgid , 'author' )
211+ authname = users .safeget (authid , 'realname' )
212+ if not authname :
213+ authname = users .safeget (authid , 'username' , '' )
214+ authaddr = users .safeget (authid , 'address' , '' )
215+ if authaddr :
216+ authaddr = " <%s>" % straddr ( ('' ,authaddr ) )
225217
226218 # make the message body
227219 m = ['' ]
@@ -241,8 +233,7 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None):
241233 m .append ('' )
242234
243235 # add the content
244- if msgid :
245- m .append (messages .get (msgid , 'content' ))
236+ m .append (messages .safeget (msgid , 'content' , '' ))
246237
247238 # add the change note
248239 if note :
0 commit comments