From 715154ead7873c410688e7d75e3109a139767f29 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 11 Sep 2021 18:48:59 -0400 Subject: [PATCH] Simply set the default collection and reference it when needed. --- keyring/backends/libsecret.py | 4 ++-- tests/backends/test_libsecret.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/keyring/backends/libsecret.py b/keyring/backends/libsecret.py index 5b4fbd96..51d7f630 100644 --- a/keyring/backends/libsecret.py +++ b/keyring/backends/libsecret.py @@ -40,6 +40,7 @@ class Keyring(KeyringBackend): "username": Secret.SchemaAttributeType.STRING, }, ) + collection = Secret.COLLECTION_DEFAULT @properties.ClassProperty @classmethod @@ -77,7 +78,6 @@ def get_password(self, service, username): def set_password(self, service, username, password): """Set password for the username of the service""" - collection = getattr(self, 'preferred_collection', Secret.COLLECTION_DEFAULT) attributes = { "application": self.appid, "service": service, @@ -86,7 +86,7 @@ def set_password(self, service, username, password): label = "Password for '{}' on '{}'".format(username, service) try: stored = Secret.password_store_sync( - self.schema, attributes, collection, label, password, None + self.schema, attributes, self.collection, label, password, None ) except GLib.Error as error: quark = GLib.quark_try_string('secret-error') diff --git a/tests/backends/test_libsecret.py b/tests/backends/test_libsecret.py index a4cf7901..50fc2b84 100644 --- a/tests/backends/test_libsecret.py +++ b/tests/backends/test_libsecret.py @@ -18,7 +18,7 @@ def init_keyring(self): "password prompts are for this keyring" ) keyring = libsecret.Keyring() - keyring.preferred_collection = 'session' + keyring.collection = 'session' return keyring