示例#1
0
文件: response.py 项目: geertj/draco2
 def absolute_uri(self, uri, scheme=None, host=None):
     """If `uri' is a relative URI, add scheme and host."""
     if not scheme:
         if self.m_request.isssl():
             scheme = 'https'
         else:
             scheme = 'http'
     if not host:
         host = self.m_request.servername()
     docroot = self.m_request.docroot()
     uri = dracouri.paste_draco_uri(uri, docroot, scheme=scheme, host=host)
     return uri
示例#2
0
文件: response.py 项目: geertj/draco2
    def paste_uri(self, uri, scheme=None, host=None, directory=None,
                  filename=None, locale=None, session=None, pathinfo=None,
                  args=None):
        """Paste into an URI.

        The arguments specify values to paste into `uri' in case it does
        not contain that component.
        """
        if callable(uri):
            extension = self.m_api.options['extension']
            uri = dracouri.uri_from_method(uri, extension)
        if isinstance(pathinfo, list):
            pathinfo = '/'.join(pathinfo)
        if isinstance(args, dict):
            args = urimod.create_query(args)
        docroot = self.m_request.docroot()
        return dracouri.paste_draco_uri(uri, docroot, scheme, host, directory,
                                        filename, locale, session, pathinfo,
                                        args)