quantum源码分析2
2013-08-12 14:32
141 查看
class Controller(object): """WSGI app that dispatched to methods. 与Method对应的controller,上面说到,一个路由表会指定一个controller。 WSGI app that reads routing information supplied by RoutesMiddleware and calls the requested action method upon itself. All action methods must, in addition to their normal parameters, accept a 'req' argument which is the incoming wsgi.Request. They raise a webob.exc exception, or return a dict which will be serialized by requested content type. """ #装饰为一个WSGI应用 @webob.dec.wsgify(RequestClass=Request) def __call__(self, req): """ Call the method specified in req.environ by RoutesMiddleware. """ arg_dict = req.environ['wsgiorg.routing_args'][1] action = arg_dict['action'] method = getattr(self, action) del arg_dict['controller'] del arg_dict['action'] if 'format' in arg_dict: del arg_dict['format'] arg_dict['request'] = req #执行方法,这里是一个抽象,子类继承后决定具体怎么执行 result = method(**arg_dict)
相关文章推荐
- quantum源码分析
- g723源码详细分析-14-感知加权滤波器补充
- 最新版ffmpeg源码分析二:transcode()函数
- jquery-jquery源码分析学习地址
- Erlang千万级用户游戏框架(Openpoker)源码文件分析清单
- c# AntiSocialRobots 源码分析
- 基于RobHess源码的sift全景图像合成过程分析
- 从Caffe源码分析训练过程
- Kafka源码分析(1)
- STL源码分析(2) -- list.h分析(1)
- Volley源码分析(五)Volley源码总结篇
- Mybatis源码分析(一)--Mapper的动态代理
- android拨号的源码分析
- Mina源码分析之数据读写
- Nginx源码分析--数组(转)
- Orchard源码分析(5.1):Host初始化(DefaultOrchardHost.Initialize方法)
- tensorflow版本SSD网络源码分析
- Storm-源码分析- spout (backtype.storm.spout)
- Tomcat源码分析之Server与Lifecycle的设计与实现
- Heritrix1.14源码分析(11) Heritrix中的URL--CandidateURI和CrawlURI以及如何增加自己的属性