示例#1
0
    def __init__(self, f, url, methods, accepts, produces, cache):
        self.__url = url
        self.__methods = methods if isinstance(methods, tuple) else (methods,)
        self.__accepts = accepts if isinstance(accepts, tuple) else (accepts,)
        self.__produces = produces
        self.__cache = cache
        self.__f = f
        self.__argConverters = {}  # dict of arg names -> group index
        self.__validators = {}
        self.__mandatory = getMandatoryArgumentNames(f)[2:]

        # parse URL into regex used for matching
        m = UrlRouter.__urlMatcher.findall(url)

        self.__matchUrl = "^%s$" % url
        for match in m:
            if len(match[0]) == 0:
                # string
                self.__argConverters[match[1]] = None
                self.__matchUrl = self.__matchUrl.replace(
                    "<%s>" % match[1], UrlRouter.__urlRegexReplace[match[0]].replace("arg", match[1])
                )
            else:
                # non string
                self.__argConverters[match[1]] = UrlRouter.__typeConverters[match[0]]
                self.__matchUrl = self.__matchUrl.replace(
                    "<%s:%s>" % match, UrlRouter.__urlRegexReplace[match[0]].replace("arg", match[1])
                )

        self.__matcher = re.compile(self.__matchUrl)
示例#2
0
 def __init__(self,f,url,methods,accepts,produces,cache):
     self.__f = f
     self.__url = url
     self.__methods = methods if isinstance(methods,tuple) else (methods,)
     self.__accepts = accepts if isinstance(accepts,tuple) else (accepts,)
     self.__produces = produces
     self.__cache = cache
     self.__argConverters = {} # dict of arg names -> group index
     self.__validators = {}
     self.__mandatory = getMandatoryArgumentNames(f)[2:]
示例#3
0
 def __init__(self, f, url, methods, accepts, produces, cache):
     self.__f = f
     self.__url = url
     self.__methods = methods if isinstance(methods, tuple) else (methods, )
     self.__accepts = accepts if isinstance(accepts, tuple) else (accepts, )
     self.__produces = produces
     self.__cache = cache
     self.__argConverters = {}  # dict of arg names -> group index
     self.__validators = {}
     self.__mandatory = getMandatoryArgumentNames(f)[2:]