[kupfer: 9/13] plugin.google_translate: fix languages list cache.
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer: 9/13] plugin.google_translate: fix languages list cache.
- Date: Tue, 3 Nov 2009 12:00:42 +0000 (UTC)
commit e5c263287317721966ad03c08f4618c0ffe1b6a1
Author: Karol BÄ?dkowski <karol bedkowsk+gh gmail com>
Date: Fri Oct 30 16:54:54 2009 +0100
plugin.google_translate: fix languages list cache.
List of Languages is now global objects.
kupfer/plugin/google_translate.py | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/plugin/google_translate.py b/kupfer/plugin/google_translate.py
index ea18861..2e7abf8 100644
--- a/kupfer/plugin/google_translate.py
+++ b/kupfer/plugin/google_translate.py
@@ -159,19 +159,22 @@ class _Language(Leaf):
return icons.ComposedIcon("text-x-generic","preferences-desktop-locale")
+# cache for Languages (load it once)
+_LANG_CACHE = None
+
class _LangSource(Source):
- _LANG_CACHE = None
def __init__(self):
Source.__init__(self, _("Languages"))
def get_items(self):
- if not self._LANG_CACHE:
- self._LANG_CACHE = tuple((
+ global _LANG_CACHE
+ if not _LANG_CACHE:
+ _LANG_CACHE = tuple((
_Language(key, name.title())
for key, name in _load_languages()
))
- return self._LANG_CACHE
+ return _LANG_CACHE
def provides(self):
yield _Language
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]