Ejemplo n.º 1
0
 def __init__(self, redirect_to, **kwargs):
     HttpResponse.__init__(self)
     if kwargs:
         dest = urlparse.quote(redirect_to, safe=RESERVED_CHARS) + "?" + urlparse.urlencode(kwargs)
     else:
         dest = urlparse.quote(redirect_to, safe=RESERVED_CHARS)
     self[b'Location'] = dest
Ejemplo n.º 2
0
def GetChartQuery(data,
                  cht,
                  chc="corp",
                  chs=(350, 200),
                  dataencoding="s",
                  chl=None,
                  chly=None,
                  chld=None,
                  chco=None,
                  **kwargs):
    """Construct the query part of a chart URL.
  """
    params = {"cht": cht, "chc": chc, "chs": "%sx%s" % chs}
    # Use default minimum 0 as reference when we draw any type of bar graphs
    if cht.startswith("b"):
        params["chd"] = _EncodeData(data, dataencoding, True)
    else:
        params["chd"] = _EncodeData(data, dataencoding)
    if chl:
        params["chl"] = EncodeLabels(chl)
    if chly:
        params["chly"] = EncodeLabels(chly)
    if chld:
        params["chld"] = EncodeLabels(chld)
    if chco:
        params["chco"] = _EncodeComma(chco)
    params.update(kwargs)
    return urlencode(params)
Ejemplo n.º 3
0
 def __init__(self, redirect_to, **kwargs):
     HttpResponse.__init__(self)
     if kwargs:
         dest = urlparse.quote(
             redirect_to,
             safe=RESERVED_CHARS) + "?" + urlparse.urlencode(kwargs)
     else:
         dest = urlparse.quote(redirect_to, safe=RESERVED_CHARS)
     self[b'Location'] = dest
Ejemplo n.º 4
0
    def get_URLencoded_poster(self):
        """Initialze a Curl object for a single POST request.

        Returns a tuple of initialized Curl and HTTPResponse objects.
        """
        data = urlparse.urlencode(self._data, True)
        c = pycurl.Curl()
        resp = HTTPResponse(self._encoding)
        c.setopt(c.URL, str(self._url))
        c.setopt(pycurl.POST, 1)
        c.setopt(pycurl.POSTFIELDS, data)
        c.setopt(c.WRITEFUNCTION, resp._body_callback)
        c.setopt(c.HEADERFUNCTION, resp._header_callback)
        headers = self._headers[:]
        headers.append(httputils.ContentType("application/x-www-form-urlencoded"))
        headers.append(httputils.ContentLength(str(len(data))))
        c.setopt(c.HTTPHEADER, map(str, headers))
        self._set_common(c)
        return c, resp
Ejemplo n.º 5
0
    def get_URLencoded_poster(self):
        """Initialze a Curl object for a single POST request.

        Returns a tuple of initialized Curl and HTTPResponse objects.
        """
        data = urlparse.urlencode(self._data, True)
        c = pycurl.Curl()
        resp = HTTPResponse(self._encoding)
        c.setopt(c.URL, str(self._url))
        c.setopt(pycurl.POST, 1)
        c.setopt(pycurl.POSTFIELDS, data)
        c.setopt(c.WRITEFUNCTION, resp._body_callback)
        c.setopt(c.HEADERFUNCTION, resp._header_callback)
        headers = self._headers[:]
        headers.append(
            httputils.ContentType("application/x-www-form-urlencoded"))
        headers.append(httputils.ContentLength(str(len(data))))
        c.setopt(c.HTTPHEADER, map(str, headers))
        self._set_common(c)
        return c, resp