def __call__(self, environ, start_response):
        """Respond to a request when called in the usual WSGI way."""
        path_info = environ.get('PATH_INFO', '')
        full_path = self._full_path(path_info)
        if not self._is_under_root(full_path):
            return self.not_found(environ, start_response)
        if path.isdir(full_path):
            if full_path[-1] <> '/' or full_path == self.root:
                location = util.request_uri(environ, include_query=False) + '/'
                if environ.get('QUERY_STRING'):
                    location += '?' + environ.get('QUERY_STRING')
                headers = [('Location', location)]
                return self.moved_permanently(environ, start_response, headers)
            else:
                full_path = self._full_path(path_info + self.index_file)
        try:
            sz = int(environ['CONTENT_LENGTH'])
        except:
            sz = 0
        if environ['REQUEST_METHOD'] == 'PUT' and sz > 0:
            for putglob in self.puttable:
                if fnmatch(path_info, putglob):
                    data = environ['wsgi.input'].read(sz)
                    try:
                        with open(full_path, "wb") as f: f.write(data)
                        return self.success_no_content(environ, start_response)
                    except:
                        print sys.exc_info()[1]
                        return self.server_error(environ, start_response)
        if environ['REQUEST_METHOD'] not in ('GET', 'HEAD'):
            headers = [('Allow', 'GET, HEAD')]
            return self.method_not_allowed(environ, start_response, headers)
        content_type = self._guess_type(full_path)
        try:
            etag, last_modified = self._conditions(full_path, environ)
            headers = [('Date', rfc822.formatdate(time.time())),
                       ('Last-Modified', last_modified),
                       ('ETag', etag)]
            if_modified = environ.get('HTTP_IF_MODIFIED_SINCE')
            if if_modified and (rfc822.parsedate(if_modified)
                                >= rfc822.parsedate(last_modified)):
                return self.not_modified(environ, start_response, headers)
            if_none = environ.get('HTTP_IF_NONE_MATCH')
            if if_none and (if_none == '*' or etag in if_none):
                return self.not_modified(environ, start_response, headers)
            file_like = self._file_like(full_path)
            headers.append(('Content-Type', content_type))
            start_response("200 OK", headers)
            if environ['REQUEST_METHOD'] == 'GET':
                return self._body(full_path, environ, file_like)
            else:
                return ['']
        except (IOError, __HOLE__), e:
            print e
            return self.not_found(environ, start_response)
dataset/ETHPy150Open cloudera/hue/tools/ace-editor/static.py/Cling.__call__