Skip to content

Commit edeae19

Browse files
author
Richard Jones
committed
Forward-porting of fixes from the maintenance branch.
1 parent edfb042 commit edeae19

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

roundup/cgi/actions.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,16 @@ def handle(self):
637637

638638
# nice message
639639
message = _('You are now registered, welcome!')
640-
641-
# redirect to the user's page
642-
raise Redirect, '%suser%s?@ok_message=%s'%(self.base,
643-
self.userid, urllib.quote(message))
640+
url = '%suser%s?@ok_message=%s'%(self.base, self.userid,
641+
urllib.quote(message))
642+
643+
# redirect to the user's page (but not 302, as some email clients seem
644+
# to want to reload the page, or something)
645+
return '''<html><head><title>%s</title></head>
646+
<body><p><a href="%s">%s</a></p>
647+
<script type="text/javascript">
648+
window.setTimeout('window.location = "%s"', 1000);
649+
</script>'''%(message, url, message, url)
644650

645651
class RegisterAction(Action):
646652
name = 'register'

roundup/cgi/client.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.162 2004-02-20 03:48:16 richard Exp $
1+
# $Id: client.py,v 1.163 2004-02-25 03:24:43 richard Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -190,7 +190,11 @@ def inner_main(self):
190190

191191
# possibly handle a form submit action (may change self.classname
192192
# and self.template, and may also append error/ok_messages)
193-
self.handle_action()
193+
html = self.handle_action()
194+
195+
if html:
196+
self.write(html)
197+
return
194198

195199
# now render the page
196200
# we don't want clients caching our dynamic pages
@@ -538,6 +542,9 @@ def handle_action(self):
538542
The action is defined by the form variable :action which
539543
identifies the method on this object to call. The actions
540544
are defined in the "actions" sequence on this class.
545+
546+
Actions may return a page (by default HTML) to return to the
547+
user, bypassing the usual template rendering.
541548
'''
542549
if self.form.has_key(':action'):
543550
action = self.form[':action'].value.lower()
@@ -556,9 +563,9 @@ def handle_action(self):
556563
# call the mapped action
557564
if isinstance(action_klass, type('')):
558565
# old way of specifying actions
559-
getattr(self, action_klass)()
566+
return getattr(self, action_klass)()
560567
else:
561-
action_klass(self).execute()
568+
return action_klass(self).execute()
562569

563570
except ValueError, err:
564571
self.error_message.append(str(err))

0 commit comments

Comments
 (0)