def _setup_ext_routes(self, mapper, ext_mgr, init_only): """ 针对get_resources方法中的controller类中的扩展方法实现生成路由表; """ """ API扩展文件中,实现get_resources方法; """ for resource in ext_mgr.get_resources(): LOG.debug(_('Extending resource: %s'), resource.collection) if init_only is not None and resource.collection not in init_only: continue inherits = None if resource.inherits: inherits = self.resources.get(resource.inherits) if not resource.controller: resource.controller = inherits.controller """ 针对get_resources方法中的controller类: """ wsgi_resource = wsgi.Resource(resource.controller, inherits=inherits) self.resources[resource.collection] = wsgi_resource kargs = dict(controller=wsgi_resource, collection=resource.collection_actions, member=resource.member_actions) if resource.parent: kargs['parent_resource'] = resource.parent """ 针对get_resources方法中的controller类中的扩展方法实现生成路由表; """ mapper.resource(resource.collection, resource.collection, **kargs) if resource.custom_routes_fn: resource.custom_routes_fn(mapper, wsgi_resource)
def create_resource(): return wsgi.Resource(Controller())
def create_resource(): return wsgi.Resource(VersionV2())