开发者

Error handling in the RequestHandler without embedding in URI

开发者 https://www.devze.com 2022-12-17 00:31 出处:网络
When a user sends a filled form, I want to print an error message in case there is an input error. One of the GAE sample codes does this by embedding the error message in the URI.

When a user sends a filled form, I want to print an error message in case there is an input error. One of the GAE sample codes does this by embedding the error message in the URI.

Inside the form handler (get):

self.redirect('/compos开发者_开发百科e?error_message=%s' % message)

and in the handler (get) of redirected URI, gets the message from request:

values = {
    'error_message': self.request.get('error_message'),
    ...

Is there a way to accomplish the same without embedding the message in the URI?


Is the values dict being rendered by the template engine? If so, you can pass the error string directly like this:

values = {
    'error_message': 'there is an error',
    ...
0

精彩评论

暂无评论...
验证码 换一张
取 消