summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2017-02-23 18:11:49 -0300
committerdrebs <drebs@leap.se>2017-02-23 18:11:49 -0300
commit459c5efd59e2ebaa21e5c461c275d866a43534e8 (patch)
treeabcb25f4552c724c3434f5198f941d3c4d3fec88
parent1ab75f97d77f9883c4d83d43513d9d47dfb397d9 (diff)
[refactor] add EmitMixin for a cleaner emitting experience
-rw-r--r--client/src/leap/soledad/client/_secrets/__init__.py7
-rw-r--r--client/src/leap/soledad/client/_secrets/storage.py12
-rw-r--r--client/src/leap/soledad/client/_secrets/util.py7
3 files changed, 13 insertions, 13 deletions
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):
@@ -44,14 +44,6 @@ class SecretsStorage(object):
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):