我正在收集用户提交的故事,一个谷歌App Engine的项目显示错误。如何重定向,然后用谷歌应用程序引擎
这是我在我的请求处理程序的POST方法处理提交的错误:
# get the title and content using self.request.get()
errors = []
if not title:
errors.append("Please enter a title.")
if not content:
errors.append("Please enter a story.")
if not errors:
# create the story, save it to the database
# redirect to the story's page
else:
# pass the title and/or content to a template
# pass the error message(s) to a template
# the same template that displays the submission form is used here
问题:,因为我的形式发送职位,以example.com/createstory.do - 如果有错误,我最终重新显示在该地址的表单页面。
我希望发生什么:将用户重定向回原来的位置提交表单的页面:example.com/Share,而在同一时间显示错误消息,并重新显示提交的表单数据。
这样做最简单的方法是什么?
我知道我可以只有/共享处理获取和发布请求,但我正在寻找一种解决方案,即使在做这样做时不会是一种选择。
会是好使用类似的urllib请求页面,并设置标题? docs:http://code.google.com/appengine/docs/python/urlfetch/overview.html – wings 2009-10-08 15:54:41