comparison roundup/admin.py @ 6430:ff4ab763f47c

issue2551141 - roundup-admin returns no such class when restoring item with duplicate key Fix the error by splitting the class name lookup and the restore opertation. Both can return KeyErrors. Set up two different try blocks for each case. Also test restore/retire.
author John Rouillard <rouilj@ieee.org>
date Sat, 05 Jun 2021 23:43:42 -0400
parents 51a1a9b0f567
children ada1edcc9132
comparison
equal deleted inserted replaced
6429:d30c3191b6e6 6430:ff4ab763f47c
1248 try: 1248 try:
1249 classname, nodeid = hyperdb.splitDesignator(designator) 1249 classname, nodeid = hyperdb.splitDesignator(designator)
1250 except hyperdb.DesignatorError as message: 1250 except hyperdb.DesignatorError as message:
1251 raise UsageError(message) 1251 raise UsageError(message)
1252 try: 1252 try:
1253 self.db.getclass(classname).restore(nodeid) 1253 dbclass = self.db.getclass(classname)
1254 except KeyError: 1254 except KeyError:
1255 raise UsageError(_('no such class "%(classname)s"') % locals()) 1255 raise UsageError(_('no such class "%(classname)s"') % locals())
1256 try:
1257 dbclass.restore(nodeid)
1258 except KeyError as e:
1259 raise UsageError(e.args[0])
1256 except IndexError: 1260 except IndexError:
1257 raise UsageError(_('no such %(classname)s node ' 1261 raise UsageError(_('no such %(classname)s node '
1258 '" % (nodeid)s"')%locals()) 1262 '" % (nodeid)s"')%locals())
1259 self.db_uncommitted = True 1263 self.db_uncommitted = True
1260 return 0 1264 return 0

Roundup Issue Tracker: http://roundup-tracker.org/