Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
commit 999665f1f881851b9316b34908945a5a4c050e94 Author: Peter Hatina phatina@redhat.com Date: Tue Oct 30 21:58:27 2012 +0100
cache class names in _LmiShellClient::getClassNames()
cli-tools/lmi/lmi_client_shell.py | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index e362355..88e4fd0 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -248,9 +248,17 @@ class _LmiInstance(BaseObject): class _LmiShellClient(LmiBaseClient): def __init__(self, hostname, username = "", password = ""): super(self.__class__, self).__init__(hostname, username, password) - - def getClassNames(self, namespace = None): - return self._getClassNames(namespace, DeepInheritance = True) + self.m_cache_class_names = {} + + def getClassNames(self, namespace = None, use_cache = True): + errorstr = "" + ns = namespace if namespace else "none" + if ns not in self.m_cache_class_names or not use_cache: + (class_names, errorstr) = self._getClassNames(namespace, DeepInheritance = True) + if not class_names: + return (None, errorstr) + self.m_cache_class_names[ns] = class_names + return (self.m_cache_class_names[ns], errorstr)
def getInstances(self, class_name, filter_key = "", **kwargs): (instance_list, _) = self._getInstances(class_name, filter_key, **kwargs)
cura-tools-devel@lists.fedorahosted.org