How does this "simplify" the URL construction? This is *far* less readable than the original.
On Mon, May 10, 2010 at 11:30 AM, Michael Hanselmann <han...@google.com>wrote: > --- > lib/rapi/client.py | 28 ++++++++-------------------- > 1 files changed, 8 insertions(+), 20 deletions(-) > > diff --git a/lib/rapi/client.py b/lib/rapi/client.py > index c920bd8..dd58ecc 100644 > --- a/lib/rapi/client.py > +++ b/lib/rapi/client.py > @@ -357,24 +357,6 @@ class GanetiRapiClient(object): > "User-Agent": self.USER_AGENT, > } > > - def _MakeUrl(self, path, query=None): > - """Constructs the URL to pass to the HTTP client. > - > - @type path: str > - @param path: HTTP URL path > - @type query: list of two-tuples > - @param query: query arguments to pass to urllib.urlencode > - > - @rtype: str > - @return: URL path > - > - """ > - return "https://%(host)s:%(port)d%(path)s?%(query)s" % { > - "host": self._host, > - "port": self._port, > - "path": path, > - "query": urllib.urlencode(query or [])} > - > def _SendRequest(self, method, path, query=None, content=None): > """Sends an HTTP request. > > @@ -397,14 +379,20 @@ class GanetiRapiClient(object): > @raises GanetiApiError: If an invalid response is returned > > """ > + assert path.startswith("/") > + > if content: > encoded_content = _JSON_ENCODER.encode(content) > else: > encoded_content = None > > - url = self._MakeUrl(path, query) > + # Build URL > + url = [self._base_url, path] > + if query: > + url.append("?") > + url.append(urllib.urlencode(query)) > > - req = _RapiRequest(method, url, self._headers, encoded_content) > + req = _RapiRequest(method, "".join(url), self._headers, > encoded_content) > > try: > resp = self._http.open(req) > -- > 1.7.0.4 > >