示例#1
0
def get_route_arg_info(route):
    r_args, _, _, r_defaults = getargspec(route.endpoint)
    r_defaults = dict(reversed(zip(reversed(r_args),
                                   reversed(r_defaults or []))))
    arg_srcs = []
    for arg in r_args:
        arg_src = {'name': arg}
        source = None
        if arg in RESERVED_ARGS:
            source = 'builtin'
        elif arg in route.path_args:
            source = 'url'
        elif arg in route._resources:
            source = 'resources'
        else:
            for mw in route._middlewares:
                if arg in mw.provides:
                    source = 'middleware'
                    break
        if source is None:
            if arg in r_defaults:
                source = 'default'
        arg_src['source'] = source
        arg_srcs.append(arg_src)
    # TODO: trace to application if middleware/resource
    return arg_srcs
示例#2
0
文件: core.py 项目: plowman/clastic
 def get_info(self):
     ret = {}
     route = self
     ep_args, _, _, ep_defaults = getargspec(route.endpoint)
     ep_defaults = dict(reversed(zip(reversed(ep_args),
                                     reversed(ep_defaults or []))))
     ret['url_rule'] = route.rule
     ret['endpoint'] = route.endpoint
     ret['endpoint_args'] = ep_args
     ret['endpoint_defaults'] = ep_defaults
     ret['render_arg'] = route.render_arg
     srcs = {}
     for arg in route.endpoint_args:
         if arg in RESERVED_ARGS:
             srcs[arg] = 'builtin'
         elif arg in route.arguments:
             srcs[arg] = 'url'
         elif arg in ep_defaults:
             srcs[arg] = 'default'
         for mw in route._middlewares:
             if arg in mw.provides:
                 srcs[arg] = mw
         if arg in route._resources:
             srcs[arg] = 'resources'
         # TODO: trace to application if middleware/resource
     ret['sources'] = srcs
     return ret
示例#3
0
 def sinter_compatible_decorator(f):
     argspec = getargspec(f)
     if argspec.varargs or argspec.keywords:
         raise TypeError("clastic does not support functions with *args" " or **kwargs: %r" % f)
     ret = subdecorator(f)
     ret._argspec = argspec
     return ret
示例#4
0
 def sinter_compatible_decorator(f):
     argspec = getargspec(f)
     if argspec.varargs or argspec.keywords:
         raise TypeError('clastic does not support functions with *args'
                         ' or **kwargs: %r' % f)
     ret = subdecorator(f)
     ret._argspec = argspec
     return ret