コード例 #1
0
    def __call__(self, environ, start_response):
        # load up the config from the config file. Only needs to be
        # done once per interpreter. This is the entry point of all
        # siesta applications, so this is where we trap it.
        _conf = config.get_config()
        if _conf is None:
            import os.path
            fname = os.path.join(
                environ.get('ll.config_dir', '/local/linden/etc'),
                'indra.xml')
            config.load(fname)

        # proceed with handling the request
        self._create_routes()
        path_info = environ['PATH_INFO']
        request_method = environ['REQUEST_METHOD']
        allowed = []
        for regex, app, methods in self._routes:
            m = regex.match(path_info)
            if m:
                #print "groupdict:",m.groupdict()
                if not methods or request_method in methods:
                    environ['paste.urlvars'] = m.groupdict()
                    return app(environ, start_response)
                else:
                    allowed += methods
        if allowed:
            allowed = dict.fromkeys(allows).keys()
            allowed.sort()
            resp = exc.HTTPMethodNotAllowed(
                headers={'Allow': ', '.join(allowed)})
        else:
            resp = exc.HTTPNotFound()
        return resp(environ, start_response)
コード例 #2
0
    def __call__(self, environ, start_response):
        # load up the config from the config file. Only needs to be
        # done once per interpreter. This is the entry point of all
        # siesta applications, so this is where we trap it.
        _conf = config.get_config()
        if _conf is None:
            import os.path
            fname = os.path.join(
                environ.get('ll.config_dir', '/local/linden/etc'),
                'indra.xml')
            config.load(fname)

        # proceed with handling the request
        self._create_routes()
        path_info = environ['PATH_INFO']
        request_method = environ['REQUEST_METHOD']
        allowed = []
        for regex, app, methods in self._routes:
            m = regex.match(path_info)
            if m:
                #print "groupdict:",m.groupdict()
                if not methods or request_method in methods:
                    environ['paste.urlvars'] = m.groupdict()
                    return app(environ, start_response)
                else:
                    allowed += methods
        if allowed:
            allowed = dict.fromkeys(allows).keys()
            allowed.sort()
            resp = exc.HTTPMethodNotAllowed(
                headers={'Allow': ', '.join(allowed)})
        else:
            resp = exc.HTTPNotFound()
        return resp(environ, start_response)