From 3e015532704f2ecb3444b79dc8834dad7cdc5f16 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sat, 5 Mar 2011 16:46:24 +0100 Subject: [PATCH] [entropy.client] delay UGC interface loading as much as possible --- libraries/entropy/client/interfaces/client.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libraries/entropy/client/interfaces/client.py b/libraries/entropy/client/interfaces/client.py index bdeb25c09..7ee7c76c2 100644 --- a/libraries/entropy/client/interfaces/client.py +++ b/libraries/entropy/client/interfaces/client.py @@ -692,7 +692,7 @@ class Client(Singleton, TextInterface, LoadersMixin, CacheMixin, CalculatorsMixi etpConst['system_settings_plugins_ids']['client_plugin'] self._enabled_repos = [] - self.UGC = None + self._do_load_ugc = load_ugc self.safe_mode = 0 self._indexing = indexing self._repo_validation = repo_validation @@ -727,11 +727,6 @@ class Client(Singleton, TextInterface, LoadersMixin, CacheMixin, CalculatorsMixi self._installed_repo_enable = False self._do_open_installed_repo = False - # load User Generated Content Interface - if load_ugc: - from entropy.client.services.ugc.interfaces import Client as ugc_cl - self.UGC = ugc_cl(self) - self.xcache = xcache shell_xcache = os.getenv("ETP_NOCACHE") if shell_xcache: @@ -778,6 +773,20 @@ class Client(Singleton, TextInterface, LoadersMixin, CacheMixin, CalculatorsMixi self._can_run_sys_set_hooks = True const_debug_write(__name__, "singleton loaded") + @property + def UGC(self): + """ + User Generated Content Interface delayed loader. + """ + if not self._do_load_ugc: + return + try: + return self._ugc_intf + except AttributeError: + from entropy.client.services.ugc.interfaces import Client as ugc_cl + self._ugc_intf = ugc_cl(self) + return self._ugc_intf + def destroy(self, _from_shutdown = False): """ Destroy this Singleton instance, closing repositories, removing