From ffe21996c44553f05aa085753502bb6a86a158af Mon Sep 17 00:00:00 2001 From: Simon Kelly Date: Fri, 29 Jun 2018 17:28:24 +0200 Subject: [PATCH 1/2] set checkpoint manager when cloning --- commcare_export/commcare_hq_client.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/commcare_export/commcare_hq_client.py b/commcare_export/commcare_hq_client.py index a0222522..716a0a96 100644 --- a/commcare_export/commcare_hq_client.py +++ b/commcare_export/commcare_hq_client.py @@ -83,7 +83,19 @@ def authenticated(self, username=None, password=None, mode=AUTH_MODE_SESSION): else: raise Exception('Unknown auth mode: %s' % mode) - return CommCareHqClient(url=self.url, project=self.project, version=self.version, session=session, auth=auth) + return self._clone_with(session=session, auth=auth) + + def _clone_with(self, **kwargs): + kwargs.setdefault('version', self.version) + kwargs.setdefault('session', self.__session) + kwargs.setdefault('auth', self.__auth) + cloned = CommCareHqClient( + self.url, + self.project, + **kwargs + ) + cloned.set_checkpoint_manager(self._checkpoint_manager, **self._checkpoint_kwargs) + return cloned def get(self, resource, params=None): """ From 59df155eaa249ff384991d195b876cefe9d28672 Mon Sep 17 00:00:00 2001 From: Simon Kelly Date: Fri, 29 Jun 2018 22:09:22 +0200 Subject: [PATCH 2/2] simplify clone --- commcare_export/commcare_hq_client.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/commcare_export/commcare_hq_client.py b/commcare_export/commcare_hq_client.py index 716a0a96..f6f79514 100644 --- a/commcare_export/commcare_hq_client.py +++ b/commcare_export/commcare_hq_client.py @@ -83,16 +83,14 @@ def authenticated(self, username=None, password=None, mode=AUTH_MODE_SESSION): else: raise Exception('Unknown auth mode: %s' % mode) - return self._clone_with(session=session, auth=auth) + return self._clone_with(session, auth) - def _clone_with(self, **kwargs): - kwargs.setdefault('version', self.version) - kwargs.setdefault('session', self.__session) - kwargs.setdefault('auth', self.__auth) + def _clone_with(self, session, auth): cloned = CommCareHqClient( self.url, self.project, - **kwargs + session=session, + auth=auth ) cloned.set_checkpoint_manager(self._checkpoint_manager, **self._checkpoint_kwargs) return cloned