Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
---------------------------------------------------------------
commit 21525bac11f0b9ddc8af4aeecbcd1adf9822d759
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Sep 3 13:45:05 2013 +0200
fix class fetching for root class in lmi_isinstance() when caching enabled
---------------------------------------------------------------
cli/lmi/shell/LMIShellCache.py | 19 ++++++++++++++++---
cli/lmi/shell/LMIShellClient.py | 7 +++----
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/cli/lmi/shell/LMIShellCache.py b/cli/lmi/shell/LMIShellCache.py
index 986f3e9..ef0a966 100644
--- a/cli/lmi/shell/LMIShellCache.py
+++ b/cli/lmi/shell/LMIShellCache.py
@@ -76,17 +76,30 @@ class LMIShellCache(object):
"""
self._class_dict[cim_class.classname] = cim_class
- def get_superclass(self, classname, namespace):
+ def has_superclass(self, classname, namespace):
"""
- Returns a cached superclass to the given class name.
+ Returns True, if the cache contains superclass to the given
+ class name, False otherwise.
Arguments:
classname -- string containing a cached class name
namespace -- string containing a namespace name
"""
if not namespace in self._class_superclass_dict:
- return None
+ return False
if not classname in self._class_superclass_dict[namespace]:
+ return False
+ return True
+
+ def get_superclass(self, classname, namespace):
+ """
+ Returns a cached superclass to the given class name.
+
+ Arguments:
+ classname -- string containing a cached class name
+ namespace -- string containing a namespace name
+ """
+ if not self.has_superclass(classname, namespace):
return None
return self._class_superclass_dict[namespace][classname]
diff --git a/cli/lmi/shell/LMIShellClient.py b/cli/lmi/shell/LMIShellClient.py
index 4ebeba1..d2203b9 100644
--- a/cli/lmi/shell/LMIShellClient.py
+++ b/cli/lmi/shell/LMIShellClient.py
@@ -154,11 +154,10 @@ class LMIShellClient(LMIBaseClient):
namespace -- string containing the namespace of CIMClass
"""
if self._cache.active:
- superclass = self._cache.get_superclass(classname, namespace)
- if superclass is None:
+ if self._cache.has_superclass(classname, namespace):
+ superclass = self._cache.get_superclass(classname, namespace)
+ else:
superclass = LMIBaseClient._get_superclass(self, classname, namespace)
- if not superclass:
- return None
self._cache.add_superclass(classname, superclass, namespace)
return superclass
return LMIBaseClient._get_superclass(self, classname, namespace)