[kupfer: 9/12] settings: Use kupfer-specific keyring configuration file for fallback



commit ddcd0adbeeb107b7b616e3841288a854ff320892
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sat Feb 6 18:14:40 2010 +0100

    settings: Use kupfer-specific keyring configuration file for fallback
    
    We configure python-keyring's fallback keyring to use a configuration
    file inside Kupfer's config folder.

 kupfer/core/settings.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/core/settings.py b/kupfer/core/settings.py
index c9e3e7e..44081fc 100644
--- a/kupfer/core/settings.py
+++ b/kupfer/core/settings.py
@@ -333,6 +333,7 @@ class UserNamePassword(ExtendedSetting):
 	Username is stored in Kupfer config, password in keyring '''
 	def __init__(self, obj=None):
 		ExtendedSetting.__init__(self)
+		self._configure_keyring()
 		self.username = None
 		self.password = None
 		if obj:
@@ -342,6 +343,13 @@ class UserNamePassword(ExtendedSetting):
 	def __repr__(self):
 		return '<UserNamePassword "%s", "%s">' % (self.username, self.password)
 
+	@classmethod
+	def _configure_keyring(cls):
+		# Configure the fallback keyring's configuration file if used
+		kr = keyring.get_keyring()
+		if hasattr(kr, "file_path"):
+			kr.file_path = config.save_config_file("keyring.cfg")
+
 	def load(self, plugin_id, key, username):
 		self.password = keyring.get_password(plugin_id, username)
 		self.username = username



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