Skip to content

Commit 1c7a31c

Browse files
author
Richard Jones
committed
forward-port from maint branch
1 parent 6795335 commit 1c7a31c

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ Cleanup:
7878
Fixed:
7979
- made error on create consistent with edit when user enters invalid data
8080
for Multilink and Link form fields (sf bug 904072)
81+
- made errors from bad input in the quick "Show issue:" form more
82+
user-friendly (sf bug 904064)
8183

8284

8385
2004-02-25 0.6.6

roundup/cgi/actions.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from roundup import hyperdb, token, date, password, rcsv
44
from roundup.i18n import _
55
from roundup.cgi import templating
6-
from roundup.cgi.exceptions import Redirect, Unauthorised
6+
from roundup.cgi.exceptions import Redirect, Unauthorised, SeriousError
77
from roundup.mailgw import uidFromAddress
88

99
__all__ = ['Action', 'ShowAction', 'RetireAction', 'SearchAction',
@@ -66,7 +66,15 @@ def handle(self, typere=re.compile('[@:]type'),
6666
elif numre.match(key):
6767
n = self.form[key].value.strip()
6868
if not t:
69-
raise ValueError, 'Invalid %s number'%t
69+
raise ValueError, 'No type specified'
70+
if not n:
71+
raise SeriousError, _('No ID entered')
72+
try:
73+
int(n)
74+
except ValueError:
75+
d = {'input': n, 'classname': t}
76+
raise SeriousError, _(
77+
'"%(input)s" is not an ID (%(classname)s ID required)')%d
7078
url = '%s%s%s'%(self.db.config.TRACKER_WEB, t, n)
7179
raise Redirect, url
7280

@@ -593,7 +601,8 @@ def handle(self):
593601

594602
# generate the one-time-key and store the props for later
595603
otk = ''.join([random.choice(chars) for x in range(32)])
596-
self.db.otks.set(otk, uid=uid, __time=time.time())
604+
d = {'uid': uid, self.db.otks.timestamp: time.time()}
605+
self.db.otks.set(otk, **d)
597606

598607
# send the email
599608
tracker_name = self.db.config.TRACKER_NAME
@@ -658,7 +667,7 @@ def handle(self):
658667
659668
Return 1 on successful login.
660669
"""
661-
props = self.client.parsePropsFromForm(create=1)[0][('user', None)]
670+
props = self.client.parsePropsFromForm(create=True)[0][('user', None)]
662671

663672
# registration isn't allowed to supply roles
664673
if props.has_key('roles'):
@@ -686,7 +695,7 @@ def handle(self):
686695
props[propname] = str(value)
687696
elif isinstance(proptype, hyperdb.Password):
688697
props[propname] = str(value)
689-
props['__time'] = time.time()
698+
props[self.db.otks.timestamp] = time.time()
690699
self.db.otks.set(otk, **props)
691700

692701
# send the email

roundup/cgi/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.164 2004-02-25 03:39:53 richard Exp $
1+
# $Id: client.py,v 1.165 2004-02-25 23:27:54 richard Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -208,6 +208,8 @@ def inner_main(self):
208208

209209
# render the content
210210
self.write(self.renderContext())
211+
except SeriousError, message:
212+
self.write(str(message))
211213
except Redirect, url:
212214
# let's redirect - if the url isn't None, then we need to do
213215
# the headers, otherwise the headers have been set before the

roundup/cgi/exceptions.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,22 @@ class SendFile(Exception):
3030

3131
class SendStaticFile(Exception):
3232
"""Send a static file from the instance html directory."""
33+
34+
class SeriousError(Exception):
35+
"""Raised when we can't reasonably display an error message on a
36+
templated page.
37+
38+
The exception value will be displayed in the error page, HTML
39+
escaped.
40+
"""
41+
def __str__(self):
42+
return '''
43+
<html><head><title>Roundup issue tracker: An error has occurred</title>
44+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;">
45+
<link rel="stylesheet" type="text/css" href="_file/style.css">
46+
</head>
47+
<body class="body" marginwidth="0" marginheight="0">
48+
<p class="error-message">%s</p>
49+
</body></html>
50+
'''%cgi.escape(self.args[0])
51+

0 commit comments

Comments
 (0)