当前位置: 首页>>代码示例>>Python>>正文


Python Context.response方法代码示例

本文整理汇总了Python中context.Context.response方法的典型用法代码示例。如果您正苦于以下问题:Python Context.response方法的具体用法?Python Context.response怎么用?Python Context.response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在context.Context的用法示例。


在下文中一共展示了Context.response方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import response [as 别名]
    def __call__(self, environ, start_response):

        if (self._controllers == None
                or len(self._controllers) == 0
                or self.mapper == None):
            raise NotInitializedProperly('Missing controller to execute.')
        else:

            context = Context(environ=environ, worker = self, match_callback = self.mapper.routematch,
                            generator_callback = URLGenerator(self.mapper, environ))
            try:
                context.match()
                if context.match_dict is None:
                    req = context.request.copy()
                    if req.path_info.endswith('/'):
                        req.path_info = req.path_info.rstrip('/')
                        route = context.matcher(environ=req.environ)
                    else:
                        req.path_info = req.path_info + '/'
                        route = context.matcher(environ=req.environ)
                    
                    if route is not None:
                        raise HTTPFound('Try add/remove trailing slash.', location = req.url)
                    else:
                        raise HTTPNotFound('Requested route %s cannot be matched.' % context.request.path_url)
            
            except RoutesException:
                raise HTTPNotFound('Requested route %s cannot be matched.' % context.request.path_url, exc_info = True)
            ctrl = self._controllers.get(context.match_dict.get('controller'))
            # TODO: test if callable and raise ControllerNotInitializedProperly respectively
            ctrl(context)

        return context.response(environ, start_response) # context.return_response()
开发者ID:pborky,项目名称:pywef,代码行数:35,代码来源:worker.py


注:本文中的context.Context.response方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。