Skip to content

Commit e9c0db9

Browse files
author
Richard Jones
committed
removed safeget() from the API [SF#994750]
1 parent 348839c commit e9c0db9

File tree

4 files changed

+32
-21
lines changed

4 files changed

+32
-21
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Feature:
3232
Fixed:
3333
- postgres backend open doesn't hide corruption in schema (sf bug 956375)
3434
- *dbm-style backends nuke() method now clear id counters
35+
- removed safeget() from the API (sf bug 994750)
3536

3637

3738
2004-??-?? 0.7.7

doc/upgrading.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ steps.
1616
Migrating from 0.7.1 to 0.8.0
1717
=============================
1818

19+
0.8.0 API changes
20+
-----------------
21+
22+
Class.safeget() was removed from the API. Test your item ids before calling
23+
Class.get() instead.
24+
25+
1926
0.8.0 new tracker layout
2027
------------------------
2128

roundup/hyperdb.py

Lines changed: 1 addition & 11 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: hyperdb.py,v 1.103 2004-10-08 00:56:11 richard Exp $
18+
# $Id: hyperdb.py,v 1.104 2004-10-08 05:44:33 richard Exp $
1919

2020
"""Hyperdatabase implementation, especially field types.
2121
"""
@@ -554,16 +554,6 @@ def index(self, nodeid):
554554
'''
555555
raise NotImplementedError
556556

557-
def safeget(self, nodeid, propname, default=None):
558-
"""Safely get the value of a property on an existing node of this class.
559-
560-
Return 'default' if the node doesn't exist.
561-
"""
562-
try:
563-
return self.get(nodeid, propname)
564-
except IndexError:
565-
return default
566-
567557
def export_propnames(self):
568558
'''List the property names for export from this Class.'''
569559
propnames = self.getprops().keys()

roundup/roundupdb.py

Lines changed: 23 additions & 10 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: roundupdb.py,v 1.113 2004-10-08 01:58:43 richard Exp $
18+
# $Id: roundupdb.py,v 1.114 2004-10-08 05:44:33 richard Exp $
1919

2020
"""Extending hyperdb with types specific to issue-tracking.
2121
"""
@@ -169,8 +169,12 @@ def nosymessage(self, nodeid, msgid, oldvalues, whichnosy='nosy',
169169
list. These recipients will not be included in the To: or Cc:
170170
address lists.
171171
"""
172-
authid = self.db.msg.safeget(msgid, 'author')
173-
recipients = self.db.msg.safeget(msgid, 'recipients', [])
172+
if msgid is None:
173+
authid = '1'
174+
recipients = []
175+
else:
176+
authid = self.db.msg.get(msgid, 'author')
177+
recipients = self.db.msg.get(msgid, 'recipients', [])
174178

175179
sendto = []
176180
bcc_sendto = []
@@ -237,8 +241,12 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
237241
messages = self.db.msg
238242
files = self.db.file
239243

240-
inreplyto = messages.safeget(msgid, 'inreplyto')
241-
messageid = messages.safeget(msgid, 'messageid')
244+
if msgid is None:
245+
inreplyto = None
246+
messageid = None
247+
else:
248+
authid = messages.get(msgid, 'inreplyto')
249+
recipients = messages.get(msgid, 'messageid')
242250

243251
# make up a messageid if there isn't one (web edit)
244252
if not messageid:
@@ -255,11 +263,15 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
255263
title = self.get(nodeid, 'title') or '%s message copy'%cn
256264

257265
# figure author information
258-
authid = messages.safeget(msgid, 'author')
259-
authname = users.safeget(authid, 'realname')
266+
if msgid is None:
267+
authid = '1'
268+
authname = 'admin'
269+
else:
270+
authid = messages.get(msgid, 'author')
271+
authname = users.get(authid, 'realname')
260272
if not authname:
261-
authname = users.safeget(authid, 'username', '')
262-
authaddr = users.safeget(authid, 'address', '')
273+
authname = users.get(authid, 'username', '')
274+
authaddr = users.get(authid, 'address', '')
263275
if authaddr:
264276
authaddr = " <%s>" % straddr( ('',authaddr) )
265277

@@ -281,7 +293,8 @@ def send_message(self, nodeid, msgid, note, sendto, from_address=None,
281293
m.append('')
282294

283295
# add the content
284-
m.append(messages.safeget(msgid, 'content', ''))
296+
if msgid is not None:
297+
m.append(messages.get(msgid, 'content', ''))
285298

286299
# add the change note
287300
if note:

0 commit comments

Comments
 (0)