From 459c5efd59e2ebaa21e5c461c275d866a43534e8 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 23 Feb 2017 18:11:49 -0300 Subject: [refactor] add EmitMixin for a cleaner emitting experience --- client/src/leap/soledad/client/_secrets/__init__.py | 7 ++++--- client/src/leap/soledad/client/_secrets/storage.py | 12 ++---------- client/src/leap/soledad/client/_secrets/util.py | 7 +++++++ 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'client/src/leap') diff --git a/client/src/leap/soledad/client/_secrets/__init__.py b/client/src/leap/soledad/client/_secrets/__init__.py index 42fe5a2d..26294364 100644 --- a/client/src/leap/soledad/client/_secrets/__init__.py +++ b/client/src/leap/soledad/client/_secrets/__init__.py @@ -24,7 +24,7 @@ from leap.soledad.common.log import getLogger from leap.soledad.client._secrets.storage import SecretsStorage from leap.soledad.client._secrets.crypto import SecretsCrypto -from leap.soledad.client._secrets.util import emit +from leap.soledad.client._secrets.util import emit, EmitMixin logger = getLogger(__name__) @@ -33,7 +33,7 @@ logger = getLogger(__name__) SecretLength = namedtuple('SecretLength', 'name length') -class Secrets(object): +class Secrets(EmitMixin): # remote secret is used @@ -45,9 +45,10 @@ class Secrets(object): def __init__(self, uuid, passphrase, url, local_path, creds, userid, shared_db=None): + self._uuid = uuid self._passphrase = passphrase + self._userid = userid self._secrets = {} - self._user_data = {'uuid': uuid, 'userid': userid} self.crypto = SecretsCrypto(self.get_passphrase) self.storage = SecretsStorage( uuid, self.get_passphrase, url, local_path, creds, userid, diff --git a/client/src/leap/soledad/client/_secrets/storage.py b/client/src/leap/soledad/client/_secrets/storage.py index da3aa9d7..730926ee 100644 --- a/client/src/leap/soledad/client/_secrets/storage.py +++ b/client/src/leap/soledad/client/_secrets/storage.py @@ -25,13 +25,13 @@ from leap.soledad.common.log import getLogger from leap.soledad.common.document import SoledadDocument from leap.soledad.client.shared_db import SoledadSharedDatabase -from leap.soledad.client._secrets.util import emit +from leap.soledad.client._secrets.util import emit, EmitMixin logger = getLogger(__name__) -class SecretsStorage(object): +class SecretsStorage(EmitMixin): def __init__(self, uuid, get_pass, url, local_path, creds, userid, shared_db=None): @@ -43,14 +43,6 @@ class SecretsStorage(object): self._shared_db = shared_db or self._init_shared_db(url, creds) self.__remote_doc = None - # - # properties - # - - @property - def _user_data(self): - return {'uuid': self._uuid, 'userid': self._userid} - # # local storage # diff --git a/client/src/leap/soledad/client/_secrets/util.py b/client/src/leap/soledad/client/_secrets/util.py index f75b2bb6..0dcdd3af 100644 --- a/client/src/leap/soledad/client/_secrets/util.py +++ b/client/src/leap/soledad/client/_secrets/util.py @@ -23,6 +23,13 @@ class SecretsError(Exception): pass +class EmitMixin(object): + + @property + def _user_data(self): + return {'uuid': self._uuid, 'userid': self._userid} + + def emit(verb): def _decorator(method): def _decorated(self, *args, **kwargs): -- cgit v1.2.3