Mercurial > p > roundup > code
diff 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 |
line wrap: on
line diff
--- a/roundup/admin.py Fri Jun 04 22:58:22 2021 -0400 +++ b/roundup/admin.py Sat Jun 05 23:43:42 2021 -0400 @@ -1250,9 +1250,13 @@ except hyperdb.DesignatorError as message: raise UsageError(message) try: - self.db.getclass(classname).restore(nodeid) + dbclass = self.db.getclass(classname) except KeyError: raise UsageError(_('no such class "%(classname)s"') % locals()) + try: + dbclass.restore(nodeid) + except KeyError as e: + raise UsageError(e.args[0]) except IndexError: raise UsageError(_('no such %(classname)s node ' '" % (nodeid)s"')%locals())
