Server.Transfer有点像重定向,只是它不是请求浏览器进行另一个页面获取,而是触发一个内部请求,使请求处理程序"转到"另一个请求处理程序。
在谷歌应用引擎中有类似的Python吗?
编辑:webapp2
对于大多数Python框架,请求处理程序只是一个函数:我想您可以导入您想要使用的实际处理程序函数,并将您在当前处理程序函数中收到的参数传递给它。
在Django中(例如(:通常有一个函数至少需要一个参数,即request
对象。您应该能够简单地导入下一个处理程序,然后返回执行结果
def actual_update_app_queue_settings(request):
return HttpResponse()
def update_app_queue_settings(request):
return actual_update_app_queue_settings(request):
对于您提到的框架,可能是这样的:
class ProductHandler(webapp2.RequestHandler):
def get(self, product_id):
self.response.write('You requested product %r.' % product_id)
class ProductHandler2(webapp2.RequestHandler):
def get(self, product_id):
nph = ProductHandler()
nph.initialize(request, response)
nph.get(product_id)
我通过看http://webapp-improved.appspot.com/guide/handlers.html:这看起来很合理。如果你使用路由注释,我真的不确定你会做什么,但这可能会做到。
通常,您只需要调用相应的方法。为了更具体。。。您正在使用哪种口味的AppEngine?Java、Python、Go。。。Php?
如果使用java/servlet,则"转发"是
protected void doGet(HttpServletRequest request, HttpServletResponse response){
request.getRequestDispatcher("/newurl").forward(request, response);
}