コード例 #1
0
ファイル: staticfiles.py プロジェクト: wendy-king/x7_venv
    def get_static_file(self, req, path, file, mimetype=None, root="content/"):
        resp = Response()

        if mimetype == None:
            if utils.is_xml_response(req):
                mimetype = "application/xml"
            elif utils.is_json_response(req):
                mimetype = "application/json"

        basename, extension = os.path.splitext(file)
        if extension == None or extension == '':
            if mimetype == "application/xml":
                resp_file = "%s%s%s.xml" % (root, path, file)
            elif mimetype == "application/json":
                resp_file = "%s%s%s.json" % (root, path, file)
            else:
                resp_file = root + path + file
        else:
            resp_file = root + path + file

        return template.static_file(resp,
                                    req,
                                    resp_file,
                                    root=utils.get_app_root(),
                                    mimetype=mimetype)
コード例 #2
0
ファイル: staticfiles.py プロジェクト: spil-jasper/keystone
    def get_static_file(self, req, path, file, mimetype=None, root="content/"):
        resp = Response()

        if mimetype is None:
            if utils.is_xml_response(req):
                mimetype = "application/xml"
            elif utils.is_json_response(req):
                mimetype = "application/json"
            else:
                logger.debug("Unhandled mime type: %s" % req.content_type)

        basename, extension = os.path.splitext(file)
        resp_file = "%s%s%s" % (root, path, file)
        if extension is None or extension == '':
            if mimetype == "application/xml":
                resp_file = "%s.xml" % resp_file
            elif mimetype == "application/json":
                resp_file = "%s.json" % resp_file

        logger.debug("Returning contents from file '%s'" % resp_file)
        return template.static_file(resp,
                                    req,
                                    resp_file,
                                    root=utils.get_app_root(),
                                    mimetype=mimetype)
コード例 #3
0
ファイル: staticfiles.py プロジェクト: kayyagari/keystone
    def get_static_file(req, path, file, mimetype=None, root="content/"):
        resp = Response()

        if mimetype is None:
            if utils.is_xml_response(req):
                mimetype = "application/xml"
            elif utils.is_json_response(req):
                mimetype = "application/json"
            else:
                logger.debug("Unhandled mime type: %s" % req.content_type)

        basename, extension = os.path.splitext(file)
        resp_file = "%s%s%s" % (root, path, file)
        if extension is None or extension == "":
            if mimetype == "application/xml":
                resp_file = "%s.xml" % resp_file
            elif mimetype == "application/json":
                resp_file = "%s.json" % resp_file

        logger.debug("Returning contents from file '%s'" % resp_file)
        return template.static_file(resp, req, resp_file, root=utils.get_app_root(), mimetype=mimetype)
コード例 #4
0
ファイル: staticfiles.py プロジェクト: AsherBond/colony
    def get_static_file(self, req, path, file, mimetype=None, root="content/"):
        resp = Response()

        if mimetype == None:
            if utils.is_xml_response(req):
                mimetype = "application/xml"
            elif utils.is_json_response(req):
                mimetype = "application/json"

        basename, extension = os.path.splitext(file)
        if extension == None or extension == '':
            if mimetype == "application/xml":
                resp_file = "%s%s%s.xml" % (root, path, file)
            elif mimetype == "application/json":
                resp_file = "%s%s%s.json" % (root, path, file)
            else:
                resp_file = root + path + file
        else:
            resp_file = root + path + file

        return template.static_file(resp, req, resp_file,
            root=utils.get_app_root(), mimetype=mimetype)