Example #1
0
    def get_extensions_info(self, req, path):
        resp = Response()

        if utils.is_xml_response(req):
            resp_file = "%s.xml" % path
            mime_type = "application/xml"
        else:
            resp_file = "%s.json" % path
            mime_type = "application/json"

        return template.static_file(resp, req, resp_file,
                root=utils.get_app_root(), mimetype=mime_type)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
 def get_xsd_atom_contract(self, req, xsd, root="content/"):
     resp = Response()
     return template.static_file(resp, req, root + "xsd/atom/" + xsd,
         root=utils.get_app_root(), mimetype="application/xml")
Example #5
0
 def get_wadl_contract(self, req, wadl, root):
     resp = Response()
     return template.static_file(resp, req, root + wadl,
         root=utils.get_app_root(), mimetype="application/vnd.sun.wadl+xml")
Example #6
0
 def get_pdf_contract(self, req, pdf, root="content/"):
     resp = Response()
     filepath = root + pdf
     return template.static_file(resp, req, filepath,
         root=utils.get_app_root(), mimetype="application/pdf")
Example #7
0
 def get_xsd_contract(self, req, xsd):
     resp = Response()
     return template.static_file(resp, req, "/xsd/" + xsd,
                           root=utils.get_app_root(),
                           mimetype="application/xml")
Example #8
0
 def get_pdf_contract(self, req):
     resp = Response()
     return template.static_file(resp, req, "content/identitydevguide.pdf",
                               root=utils.get_app_root(),
                               mimetype="application/pdf")
Example #9
0
 def __get_root(self):
     """ Returns application root.Has a local reference for reuse."""
     if self.root is None:
         self.root = utils.get_app_root()
         self.root = os.path.abspath(self.root) + os.sep
     return self.root