Skip to content

Commit 10f62fe

Browse files
author
Richard Jones
committed
made errors from bad input in the quick "Show issue:" form more user-friendly
[SF#904064]
1 parent 55835d1 commit 10f62fe

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

CHANGES.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4-
2004-02-25 0.6.7
4+
2004-??-?? 0.6.7
55
Fixed:
66
- made error on create consistent with edit when user enters invalid data
77
for Multilink and Link form fields (sf bug 904072)
8+
- made errors from bad input in the quick "Show issue:" form more
9+
user-friendly (sf bug 904064)
810

911

1012
2004-02-25 0.6.6

roundup/cgi/client.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.130.2.11 2004-02-24 23:37:10 richard Exp $
1+
# $Id: client.py,v 1.130.2.12 2004-02-25 23:23:56 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -26,6 +26,23 @@ class Redirect(HTTPException):
2626
pass
2727
class NotModified(HTTPException):
2828
pass
29+
class SeriousError(Exception):
30+
''' Raised when we can't reasonably display an error message on a
31+
templated page.
32+
33+
The exception value will be displayed in the error page, HTML
34+
escaped.
35+
'''
36+
def __str__(self):
37+
return '''
38+
<html><head><title>Roundup issue tracker: An error has occurred</title>
39+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;">
40+
<link rel="stylesheet" type="text/css" href="_file/style.css">
41+
</head>
42+
<body class="body" marginwidth="0" marginheight="0">
43+
<p class="error-message">%s</p>
44+
</body></html>
45+
'''%cgi.escape(self.args[0])
2946

3047
# set to indicate to roundup not to actually _send_ email
3148
# this var must contain a file to write the mail to
@@ -262,6 +279,8 @@ def inner_main(self):
262279

263280
# render the content
264281
self.write(self.renderContext())
282+
except SeriousError, message:
283+
self.write(str(message))
265284
except Redirect, url:
266285
# let's redirect - if the url isn't None, then we need to do
267286
# the headers, otherwise the headers have been set before the
@@ -1458,7 +1477,6 @@ def retirePermission(self):
14581477
return 0
14591478
return 1
14601479

1461-
14621480
def showAction(self, typere=re.compile('[@:]type'),
14631481
numre=re.compile('[@:]number')):
14641482
''' Show a node of a particular class/id
@@ -1470,7 +1488,18 @@ def showAction(self, typere=re.compile('[@:]type'),
14701488
elif numre.match(key):
14711489
n = self.form[key].value.strip()
14721490
if not t:
1473-
raise ValueError, 'Invalid %s number'%t
1491+
raise ValueError, 'No type specified'
1492+
return
1493+
if not n:
1494+
raise SeriousError, _('No ID entered')
1495+
return
1496+
try:
1497+
int(n)
1498+
except ValueError:
1499+
d = {'input': n, 'classname': t}
1500+
raise SeriousError, _(
1501+
'"%(input)s" is not an ID (%(classname)s ID required)')%d
1502+
return
14741503
url = '%s%s%s'%(self.db.config.TRACKER_WEB, t, n)
14751504
raise Redirect, url
14761505

0 commit comments

Comments
 (0)