[kupfer: 7/41] plugin_support: Initialize keyring early in check_keyring_support.



commit 177866283a38379996a241baec76241313c619ba
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Apr 26 18:41:07 2011 +0200

    plugin_support: Initialize keyring early in check_keyring_support.

 kupfer/plugin_support.py |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/kupfer/plugin_support.py b/kupfer/plugin_support.py
index d681e88..4d4f31c 100644
--- a/kupfer/plugin_support.py
+++ b/kupfer/plugin_support.py
@@ -148,7 +148,6 @@ class UserNamePassword (settings.ExtendedSetting):
 	Username is stored in Kupfer config, password in keyring '''
 	def __init__(self, obj=None):
 		settings.ExtendedSetting.__init__(self)
-		self._configure_keyring()
 		self.username = None
 		self.password = None
 		if obj:
@@ -160,17 +159,6 @@ class UserNamePassword (settings.ExtendedSetting):
 		                                        bool(self.password))
 
 	@classmethod
-	def _configure_keyring(cls):
-		# Configure the fallback keyring's configuration file if used
-		import keyring.backend
-		kr = keyring.get_keyring()
-		if hasattr(kr, "crypted_password"):
-			keyring.set_keyring(keyring.backend.UncryptedFileKeyring())
-			kr = keyring.get_keyring()
-		if hasattr(kr, "file_path"):
-			kr.file_path = config.save_config_file("keyring.cfg")
-
-	@classmethod
 	def is_backend_encrypted(cls):
 		import keyring.core
 		return keyring.core.get_keyring().supported() == 1
@@ -219,6 +207,15 @@ def check_keyring_support():
 		class UserNamePassword (object):
 			pass
 		raise
+	else:
+		# Configure the fallback keyring's configuration file if used
+		import keyring.backend
+		kr = keyring.get_keyring()
+		if hasattr(kr, "crypted_password"):
+			keyring.set_keyring(keyring.backend.UncryptedFileKeyring())
+			kr = keyring.get_keyring()
+		if hasattr(kr, "file_path"):
+			kr.file_path = config.save_config_file("keyring.cfg")
 	finally:
 		# now unblock kde libraries again
 		if old_pykde4:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]