summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: caa552b)
raw | patch | inline | side by side (parent: caa552b)
author | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 16 Nov 2003 22:56:46 +0000 (22:56 +0000) | ||
committer | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Sun, 16 Nov 2003 22:56:46 +0000 (22:56 +0000) |
- Remove handling of invalid propname (YAGNI).
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1998 57a73879-2fb5-44c3-a270-3262357dd7e2
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1998 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/hyperdb.py | patch | blob | history | |
test/db_test_base.py | patch | blob | history |
diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py
index 6cb47d92927f67c8d602098342179b6d704a8acb..c8ca0a57ff593596bf02f5b1e125f3e93e8ab15f 100644 (file)
--- a/roundup/hyperdb.py
+++ b/roundup/hyperdb.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: hyperdb.py,v 1.94 2003-11-16 20:01:16 jlgijsbers Exp $
+# $Id: hyperdb.py,v 1.95 2003-11-16 22:56:46 jlgijsbers Exp $
"""
Hyperdatabase implementation, especially field types.
raise NotImplementedError
def safeget(self, nodeid, propname, default=None):
+ """Safely get the value of a property on an existing node of this class.
+
+ Return 'default' if the node doesn't exist.
+ """
try:
return self.get(nodeid, propname)
- except (KeyError, IndexError):
+ except IndexError:
return default
class HyperdbValueError(ValueError):
diff --git a/test/db_test_base.py b/test/db_test_base.py
index 2435134a76620c1a22b014bf364e1771e4fe0834..d7b65be8fc51622e9c2a49592d73f8a53809145b 100644 (file)
--- a/test/db_test_base.py
+++ b/test/db_test_base.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: db_test_base.py,v 1.9 2003-11-16 19:59:06 jlgijsbers Exp $
+# $Id: db_test_base.py,v 1.10 2003-11-16 22:56:46 jlgijsbers Exp $
import unittest, os, shutil, errno, imp, sys, time, pprint
def testSafeGet(self):
# existent nodeid, existent property
self.assertEqual(self.db.user.safeget('1', 'username'), 'admin')
- # existent nodeid, nonexistent property
- self.assertEqual(self.db.user.safeget('1', 'nonexistent'), None)
# nonexistent nodeid, existent property
self.assertEqual(self.db.user.safeget('999', 'username'), None)
- # nonexistent nodeid, nonexistent property
- self.assertEqual(self.db.user.safeget('999', 'nonexistent'), None)
# different default
self.assertEqual(self.db.issue.safeget('999', 'nosy', []), [])