Use type instead of tags to get docs in openpgp
authorRuben Pollan <meskio@sindominio.net>
Mon, 10 Nov 2014 15:50:56 +0000 (09:50 -0600)
committerRuben Pollan <meskio@sindominio.net>
Mon, 10 Nov 2014 19:41:28 +0000 (13:41 -0600)
For that that now the type is the class.__name__ instead of
str(class)

src/leap/keymanager/__init__.py
src/leap/keymanager/keys.py
src/leap/keymanager/openpgp.py

index 53dd9a7..0ffb6fc 100644 (file)
@@ -134,7 +134,7 @@ class KeyManager(object):
         Return key class from string representation of key type.
         """
         return filter(
         Return key class from string representation of key type.
         """
         return filter(
-            lambda klass: str(klass) == ktype,
+            lambda klass: klass.__name__ == ktype,
             self._wrapper_map).pop()
 
     def _get(self, uri, data=None):
             self._wrapper_map).pop()
 
     def _get(self, uri, data=None):
index 4952b9b..5aeb794 100644 (file)
@@ -71,14 +71,14 @@ KEYMANAGER_KEY_TAG = 'keymanager-key'
 #
 
 TAGS_PRIVATE_INDEX = 'by-tags-private'
 #
 
 TAGS_PRIVATE_INDEX = 'by-tags-private'
-TAGS_ADDRESS_PRIVATE_INDEX = 'by-tags-address-private'
+TYPE_ADDRESS_PRIVATE_INDEX = 'by-type-address-private'
 INDEXES = {
     TAGS_PRIVATE_INDEX: [
         KEY_TAGS_KEY,
         'bool(%s)' % KEY_PRIVATE_KEY,
     ],
 INDEXES = {
     TAGS_PRIVATE_INDEX: [
         KEY_TAGS_KEY,
         'bool(%s)' % KEY_PRIVATE_KEY,
     ],
-    TAGS_ADDRESS_PRIVATE_INDEX: [
-        KEY_TAGS_KEY,
+    TYPE_ADDRESS_PRIVATE_INDEX: [
+        KEY_TYPE_KEY,
         KEY_ADDRESS_KEY,
         'bool(%s)' % KEY_PRIVATE_KEY,
     ]
         KEY_ADDRESS_KEY,
         'bool(%s)' % KEY_PRIVATE_KEY,
     ]
@@ -200,7 +200,7 @@ class EncryptionKey(object):
 
         return json.dumps({
             KEY_ADDRESS_KEY: self.address,
 
         return json.dumps({
             KEY_ADDRESS_KEY: self.address,
-            KEY_TYPE_KEY: str(self.__class__),
+            KEY_TYPE_KEY: self.__class__.__name__,
             KEY_ID_KEY: self.key_id,
             KEY_FINGERPRINT_KEY: self.fingerprint,
             KEY_DATA_KEY: self.key_data,
             KEY_ID_KEY: self.key_id,
             KEY_FINGERPRINT_KEY: self.fingerprint,
             KEY_DATA_KEY: self.key_data,
index 1160434..38db178 100644 (file)
@@ -36,8 +36,7 @@ from leap.keymanager.keys import (
     EncryptionScheme,
     is_address,
     build_key_from_dict,
     EncryptionScheme,
     is_address,
     build_key_from_dict,
-    KEYMANAGER_KEY_TAG,
-    TAGS_ADDRESS_PRIVATE_INDEX,
+    TYPE_ADDRESS_PRIVATE_INDEX,
     KEY_FINGERPRINT_KEY,
     KEY_DATA_KEY,
 )
     KEY_FINGERPRINT_KEY,
     KEY_DATA_KEY,
 )
@@ -210,6 +209,9 @@ class OpenPGPScheme(EncryptionScheme):
     signing and verification).
     """
 
     signing and verification).
     """
 
+    # type used on the soledad documents
+    OPENPGP_KEY_TYPE = OpenPGPKey.__name__
+
     def __init__(self, soledad, gpgbinary=None):
         """
         Initialize the OpenPGP wrapper.
     def __init__(self, soledad, gpgbinary=None):
         """
         Initialize the OpenPGP wrapper.
@@ -427,8 +429,8 @@ class OpenPGPScheme(EncryptionScheme):
         :rtype: leap.soledad.document.SoledadDocument
         """
         doclist = self._soledad.get_from_index(
         :rtype: leap.soledad.document.SoledadDocument
         """
         doclist = self._soledad.get_from_index(
-            TAGS_ADDRESS_PRIVATE_INDEX,
-            KEYMANAGER_KEY_TAG,
+            TYPE_ADDRESS_PRIVATE_INDEX,
+            self.OPENPGP_KEY_TYPE,
             address,
             '1' if private else '0')
         if len(doclist) is 0:
             address,
             '1' if private else '0')
         if len(doclist) is 0: