示例#1
0
    def query_string(self):
        """
        The map request as a query string (the order is not guaranteed).

        >>> qs = RequestParams(dict(foo='egg', bar='ham%eggs', baz=100)).query_string
        >>> sorted(qs.split('&'))
        ['bar=ham%25eggs', 'baz=100', 'foo=egg']
        """
        kv_pairs = []
        for key, values in self.params.iteritems():
            value = ','.join(text_type(v) for v in values)
            kv_pairs.append(key + '=' + quote(value.encode('utf-8'), safe=','))
        return '&'.join(kv_pairs)
示例#2
0
 def base_url(self):
     return (self.host_url.rstrip('/')
             + quote(self.environ.get('SCRIPT_NAME', '').rstrip('/'))
             + quote(self.environ.get('PATH_INFO', ''))
示例#3
0
 def script_url(self):
     "Full script URL without trailing /"
     return (self.host_url.rstrip('/') +
             quote(self.environ.get('SCRIPT_NAME', '/').rstrip('/'))
            )