diff --git a/phabricator/__init__.py b/phabricator/__init__.py index 40fb669..330b740 100644 --- a/phabricator/__init__.py +++ b/phabricator/__init__.py @@ -178,6 +178,12 @@ def __getitem__(self, key): def __getattr__(self, key): return self.response[key] + def __getstate__(self): + return self.response + + def __setstate__(self, state): + self.response = state + def __len__(self): return len(self.response.keys()) @@ -292,7 +298,17 @@ def __init__(self, username=None, certificate=None, host=None, # Set values in ~/.arcrc as defaults if ARCRC: - self.host = host if host else ARCRC['hosts'].keys()[0] + if host: + self.host = host + else: + hostbase = (ARCRC.get('config', {}).get('phabricator.uri') or + ARCRC.get('config', {}).get('default')) + if hostbase: + # Hardcoding the path info to '/api/' to match arcanist.php + # behavior. + self.host = urlparse.urljoin(hostbase, "/api/") + else: + self.host = ARCRC['hosts'].keys()[0] self.username = username if username else ARCRC['hosts'][self.host]['user'] self.certificate = certificate if certificate else ARCRC['hosts'][self.host]['cert'] else: