__init__.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pillar 作者: armadillica 项目源码 文件源码
def __fake_request_url_rule(self, method: str, url_path: str):
        """Tries to force-set the request URL rule.

        This is required by Eve (since 0.70) to be able to construct a
        Location HTTP header that points to the resource item.

        See post_internal, put_internal and patch_internal.
        """

        import werkzeug.exceptions as wz_exceptions

        with self.test_request_context(method=method, path=url_path) as ctx:
            try:
                rule, _ = ctx.url_adapter.match(url_path, method=method, return_rule=True)
            except (wz_exceptions.MethodNotAllowed, wz_exceptions.NotFound):
                # We're POSTing things that we haven't told Eve are POSTable. Try again using the
                # GET method.
                rule, _ = ctx.url_adapter.match(url_path, method='GET', return_rule=True)
            current_request = request._get_current_object()
            current_request.url_rule = rule

            yield ctx
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号