Mercurial > hg > AuthRPC
changeset 13:21eb67081c43
Added docstrings
author | Ben Croston <ben@croston.org> |
---|---|
date | Mon, 05 Sep 2011 12:42:05 +0100 |
parents | 4ac14cfadc15 |
children | 45c1d78559e2 |
files | wibble/client/__init__.py |
diffstat | 1 files changed, 14 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/wibble/client/__init__.py Mon Sep 05 12:29:08 2011 +0100 +++ b/wibble/client/__init__.py Mon Sep 05 12:42:05 2011 +0100 @@ -80,7 +80,7 @@ 'Accept':'application/json'} def __init__(self, uri, proxy_uri=None, user_agent=None): - self.headers['User-Agent'] = user_agent if user_agent is not None else 'jsonrpclib' + self.headers['User-Agent'] = user_agent if user_agent is not None else 'wibble' if proxy_uri is not None: self.connection_url = urlparse(proxy_uri) self.request_path = uri @@ -136,13 +136,19 @@ Exception.__init__(self,'HTTP 502 - Bad Gateway') class ServerProxy(object): - def __init__(self, uri=None, transport=None, proxy_uri=None, user_agent=None, username=None, password=None): - if uri is None and transport is None: - raise Exception('either uri or transport needs to be specified') - - if transport is None: - transport = _JSONRPCTransport(uri, proxy_uri=proxy_uri, user_agent=user_agent) - self.__transport = transport + """ + A client class to communicate with a wibble server + """ + def __init__(self, uri, proxy_uri=None, user_agent=None, username=None, password=None): + """ + uri - the URI of a corresponding wibble server + proxy_uri - the http proxy to use, if any + user_agent - user agent to be used (can be used as part of authentication) + username - username to use in requests + password - password to use in requests + """ + assert uri is not None + self.__transport = _JSONRPCTransport(uri, proxy_uri=proxy_uri, user_agent=user_agent) self._username = username self._password = password