Google app engine 谷歌应用引擎:状态代码403
如何响应403状态代码 我遵循了一个例子,上面有这样的内容:Google app engine 谷歌应用引擎:状态代码403,google-app-engine,web-applications,Google App Engine,Web Applications,如何响应403状态代码 我遵循了一个例子,上面有这样的内容:raisewebapp.Error(403)。所以我想这会给我一个403,但它只会给我一个常规的500服务器错误 这是一个完整的例子: def administrator(method): ''' credit: http://github.com/btbytes/teh/blob/master/utils.py decorator to restrict access to admin a
raisewebapp.Error(403)
。所以我想这会给我一个403,但它只会给我一个常规的500服务器错误
这是一个完整的例子:
def administrator(method):
''' credit:
http://github.com/btbytes/teh/blob/master/utils.py
decorator to restrict access to admin areas
'''
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
user = users.get_current_user()
if not user:
if self.request.method == "GET":
self.redirect(users.create_login_url(self.request.uri))
return
if not users.is_current_user_admin():
raise webapp.Error(403)
else:
return method(self, *args, **kwargs)
return wrapper
这就是我得到它的地方:使用self.error(403)
使用自身错误(403)