Mercurial > p > roundup > code
changeset 2052:78e6a1e4984e
forward-port from maint branch
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 25 Feb 2004 23:27:54 +0000 |
| parents | 5a5f66e6b0e1 |
| children | bd79245fc30c |
| files | CHANGES.txt roundup/cgi/actions.py roundup/cgi/client.py roundup/cgi/exceptions.py |
| diffstat | 4 files changed, 38 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Wed Feb 25 09:40:46 2004 +0000 +++ b/CHANGES.txt Wed Feb 25 23:27:54 2004 +0000 @@ -78,6 +78,8 @@ Fixed: - made error on create consistent with edit when user enters invalid data for Multilink and Link form fields (sf bug 904072) +- made errors from bad input in the quick "Show issue:" form more + user-friendly (sf bug 904064) 2004-02-25 0.6.6
--- a/roundup/cgi/actions.py Wed Feb 25 09:40:46 2004 +0000 +++ b/roundup/cgi/actions.py Wed Feb 25 23:27:54 2004 +0000 @@ -3,7 +3,7 @@ from roundup import hyperdb, token, date, password, rcsv from roundup.i18n import _ from roundup.cgi import templating -from roundup.cgi.exceptions import Redirect, Unauthorised +from roundup.cgi.exceptions import Redirect, Unauthorised, SeriousError from roundup.mailgw import uidFromAddress __all__ = ['Action', 'ShowAction', 'RetireAction', 'SearchAction', @@ -66,7 +66,15 @@ elif numre.match(key): n = self.form[key].value.strip() if not t: - raise ValueError, 'Invalid %s number'%t + raise ValueError, 'No type specified' + if not n: + raise SeriousError, _('No ID entered') + try: + int(n) + except ValueError: + d = {'input': n, 'classname': t} + raise SeriousError, _( + '"%(input)s" is not an ID (%(classname)s ID required)')%d url = '%s%s%s'%(self.db.config.TRACKER_WEB, t, n) raise Redirect, url @@ -593,7 +601,8 @@ # generate the one-time-key and store the props for later otk = ''.join([random.choice(chars) for x in range(32)]) - self.db.otks.set(otk, uid=uid, __time=time.time()) + d = {'uid': uid, self.db.otks.timestamp: time.time()} + self.db.otks.set(otk, **d) # send the email tracker_name = self.db.config.TRACKER_NAME @@ -658,7 +667,7 @@ Return 1 on successful login. """ - props = self.client.parsePropsFromForm(create=1)[0][('user', None)] + props = self.client.parsePropsFromForm(create=True)[0][('user', None)] # registration isn't allowed to supply roles if props.has_key('roles'): @@ -686,7 +695,7 @@ props[propname] = str(value) elif isinstance(proptype, hyperdb.Password): props[propname] = str(value) - props['__time'] = time.time() + props[self.db.otks.timestamp] = time.time() self.db.otks.set(otk, **props) # send the email
--- a/roundup/cgi/client.py Wed Feb 25 09:40:46 2004 +0000 +++ b/roundup/cgi/client.py Wed Feb 25 23:27:54 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.164 2004-02-25 03:39:53 richard Exp $ +# $Id: client.py,v 1.165 2004-02-25 23:27:54 richard Exp $ """WWW request handler (also used in the stand-alone server). """ @@ -208,6 +208,8 @@ # render the content self.write(self.renderContext()) + except SeriousError, message: + self.write(str(message)) except Redirect, url: # let's redirect - if the url isn't None, then we need to do # the headers, otherwise the headers have been set before the
--- a/roundup/cgi/exceptions.py Wed Feb 25 09:40:46 2004 +0000 +++ b/roundup/cgi/exceptions.py Wed Feb 25 23:27:54 2004 +0000 @@ -30,3 +30,22 @@ class SendStaticFile(Exception): """Send a static file from the instance html directory.""" + +class SeriousError(Exception): + """Raised when we can't reasonably display an error message on a + templated page. + + The exception value will be displayed in the error page, HTML + escaped. + """ + def __str__(self): + return ''' +<html><head><title>Roundup issue tracker: An error has occurred</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8;"> + <link rel="stylesheet" type="text/css" href="_file/style.css"> +</head> +<body class="body" marginwidth="0" marginheight="0"> + <p class="error-message">%s</p> +</body></html> +'''%cgi.escape(self.args[0]) +
