本文介绍了Google AppEngine WebApp2上的PATCH方法处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我尝试在 webapp2.RequestHandler 中使用 def patch():方法来支持部分资源更新,但后来发现允许的方法在webapp2.py中被冻结: allowed_methods = frozenset(('GET','POST '''HEAD'''OPTIONS''PUT''DELETE'TRACE')) b $ b 如何扩展 webapp2.RequestHandler 或修改 WSGIApplication 类以允许PATCH HTTP方法当部署在Google AppEngine上时?解决方案在创建 WSGIApplication : $ pre $允许_方法= PATCH',)) webapp2.WSGIApplication.allowed_methods = new_allowed_methods 当前有一个补丁在 webapp2 问题跟踪器上,但不支持一个已经拿起它。 I tried to use a def patch(): method in my webapp2.RequestHandler to support partial resource updates, but then saw that the allowed methods are frozen in webapp2.py:allowed_methods = frozenset(('GET', 'POST', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE'))How can I extend webapp2.RequestHandler or modify the WSGIApplication class to allow the PATCH HTTP method when deployed on Google AppEngine? 解决方案 Just use a monkey patch by performing this before creating a WSGIApplication:allowed_methods = webapp2.WSGIApplication.allowed_methodsnew_allowed_methods = allowed_methods.union(('PATCH',))webapp2.WSGIApplication.allowed_methods = new_allowed_methodsThere is a current patch on the webapp2 issue tracker but no one has picked it up. 这篇关于Google AppEngine WebApp2上的PATCH方法处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-21 17:29