Index: /trunk/src/VBox/Frontends/VBoxShell/mscom/vboxshell.py
===================================================================
--- /trunk/src/VBox/Frontends/VBoxShell/mscom/vboxshell.py	(revision 19813)
+++ /trunk/src/VBox/Frontends/VBoxShell/mscom/vboxshell.py	(revision 19814)
@@ -22,67 +22,77 @@
 import pythoncom
 import win32api
-import traceback
 
 from shellcommon import interpret
 
 class LocalManager:
-    def getSessionObject(self, vb):
-        return win32com.client.Dispatch("{3C02F46D-C9D2-4f11-A384-53F0CF917214}")
+	def getSessionObject(self, vb):
+		return win32com.client.Dispatch("{3C02F46D-C9D2-4f11-A384-53F0CF917214}")
+
+class ConstantFake:
+        def __init__(self, parent, name):
+                self.__dict__['_parent'] = parent
+		self.__dict__['_name'] = name
+		self.__dict__['_consts'] = {}
+        	try:
+             		self.__dict__['_depth']=parent.__dict__['_depth']+1
+        	except:
+             		self.__dict__['_depth']=0
+        	if self.__dict__['_depth'] > 4:
+			raise AttributeError
+
+	def __getattr__(self, attr):
+    		if attr.startswith("__"):
+         		raise AttributeError
+
+    		consts = self.__dict__['_consts']
+    		fake = consts.get(attr, None)
+    		if fake != None:
+         		return fake  
+    		try:
+			name = makeFullName(self, attr)
+			return win32com.client.constants.__getattr__(name)
+		except AttributeError,e:
+			fake = ConstantFake(self, attr)
+			consts[attr] = fake
+			return fake  	
+
+def makeFullName(fake, attr):
+	name = fake._name
+	parent = fake._parent
+	while parent != None:
+		if parent._name is not None:
+			name = parent._name+'_'+name
+		parent = parent._parent
+
+	if name:
+                name += "_" + attr
+        else:
+                name = attr
+	return name
+
+
+class InterfacesWrapper:
+	def __init__(self):
+    		self.__dict__['_rootFake'] = ConstantFake(None, None)
+
+  	def __getattr__(self, a):
+    		if a.startswith("__"):
+        		raise AttributeError
+    		try:
+       			return win32com.client.constants.__getattr__(a)
+    		except AttributeError,e:
+                	return self.__dict__['_rootFake'].__getattr__(a)
+
 
 vbox = None
 mgr = LocalManager()
 try:
+        win32com.client.gencache.EnsureDispatch('VirtualBox.Session') 
         vbox = win32com.client.Dispatch("{B1A7A4F2-47B9-4A1E-82B2-07CCD5323C3F}")
-        win32com.client.gencache.EnsureDispatch('VirtualBox.Session') 
 except Exception,e:
-    print "COM exception: ",e
-    traceback.print_exc()
-    sys.exit(1)
+        print "COM exception: ",e
+        traceback.print_exc()
+        sys.exit(1)
 
-class ConstantFake:
-  def __init__(self, parent, name):
-        self.__dict__['_parent'] = parent
-        self.__dict__['_name'] = name
-        try:
-             self.__dict__['_depth']=parent.__dict__['_depth']+1
-        except:
-             self.__dict__['_depth']=0
-        self.__dict__['_klazz'] = self.__class__
-        if self.__dict__['_depth'] > 4:
-                raise AttributeError
-
-  def __getattr__(self, attr):
-    if attr.startswith("__"):
-        raise AttributeError
-        
-    try:
-        n = makeFullName(self) + "_" + attr
-        v = win32com.client.constants.__getattr__(n)
-        return v
-    except AttributeError,e:
-        return ConstantFake(self, attr)
-
-def makeFullName(fake):
-        name = fake._name
-        parent = fake._parent
-        while parent != None:
-                name   = parent._name+'_'+name
-                parent = parent._parent
-        return name
-
-
-class InterfacesWrapper:
-  """COM constants name translator
-  """
-  def __init__(self):
-    pass
-
-  def __getattr__(self, a):
-    try:
-        return win32com.client.constants.__getattr__(a)
-    except AttributeError,e:
-        if a.startswith("__"):
-                raise e
-        return ConstantFake(None, a)
 
 ctx = {'mgr':mgr, 'vb':vbox, 'ifaces':InterfacesWrapper(),
