[rhmessaging-commits] rhmessaging commits: r2107 - mgmt/mint/python/mint.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Jun 2 17:29:35 EDT 2008


Author: nunofsantos
Date: 2008-06-02 17:29:35 -0400 (Mon, 02 Jun 2008)
New Revision: 2107

Modified:
   mgmt/mint/python/mint/__init__.py
Log:
workaround class names being sent in all-lowercase; handle name clash on connection attrib

Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py	2008-06-02 19:45:30 UTC (rev 2106)
+++ mgmt/mint/python/mint/__init__.py	2008-06-02 21:29:35 UTC (rev 2107)
@@ -354,7 +354,9 @@
     return "idOriginal"
 
   def convertRefKey(self, k):
-    return k.replace("Ref", "")
+    result = k.replace("Ref", "")
+    result = result[0].lower() + result[1:]
+    return result
 
   def findParentKeys(self, d):
     keys = []
@@ -375,7 +377,7 @@
 
   def configCallback(self, brokerId, classInfo, list, timestamps):
     self.log("\nCONFIG---------------------------------------------------")
-    objectName = classInfo[1]
+    objectName = classInfo[1][0].upper() + classInfo[1][1:]
     brokerUUID = classInfo[2]
     self.log(objectName)
     d = self.sanitizeDict(dict(list))
@@ -393,9 +395,13 @@
     try:
       for parentKey in self.findParentKeys(d):
         convertedKey = self.convertRefKey(parentKey)
-        cls = schema.schemaNameToClassMap.get(convertedKey)
+        cls = schema.schemaNameToClassMap.get(convertedKey[0].upper() + convertedKey[1:])
+        if (convertedKey == "connection"):
+          convertedKey = "clientConnection"
         if cls:
           d[convertedKey] = conn.getByOriginalId(cls, d.pop(parentKey), brokerId)
+        else:
+          self.log("Error: referenced class not found: %s" % convertedKey)
       obj = conn.getByOriginalId(schema.schemaNameToClassMap[objectName], d["idOriginal"], brokerId, create=True)
       if (not obj):
         self.log("Couldn't find type %s id %s" % (objectName, d["idOriginal"]))
@@ -403,10 +409,10 @@
       obj.set(**d)
       obj.syncUpdate()
     except TypeError, detail:
-      self.log("Schema mismatch: %s" % detail)
+      self.log("TypeError: Schema mismatch: %s" % detail)
       return
     except KeyError, detail:
-      self.log("Schema mismatch: %s" % detail)
+      self.log("KeyError: Schema mismatch: %s" % detail)
       return 
 
     self.log("END CONFIG---------------------------------------------------\n")
@@ -414,7 +420,7 @@
 
   def instCallback(self, brokerId, classInfo, list, timestamps):
     self.log("\nINST---------------------------------------------------")
-    objectName = classInfo[1]
+    objectName = classInfo[1][0].upper() + classInfo[1][1:]
     brokerUUID = classInfo[2]
     self.log(objectName)
     d = self.sanitizeDict(dict(list))
@@ -435,7 +441,10 @@
         print "lion", classInfo, list
         return
 
-      d[objectName] = obj
+      origObjName = classInfo[1]
+      if (origObjName == "connection"):
+        origObjName = "clientConnection"
+      d[origObjName] = obj
       objNameStats = eval("schema.%sStats" % (schema.schemaNameToClassMap[objectName].__name__))
       objStats = objNameStats.__new__(objNameStats)
       objStats.__init__()
@@ -456,10 +465,10 @@
       obj.set(**d)
       obj.syncUpdate()
     except TypeError, detail:
-      self.log("Schema mismatch: %s" % detail)
+      self.log("TypeError: Schema mismatch: %s" % detail)
       return
     except KeyError, detail:
-      self.log("Schema mismatch: %s" % detail)
+      self.log("KeyError: Schema mismatch: %s" % detail)
       return 
 
     self.log("END INST---------------------------------------------------\n")




More information about the rhmessaging-commits mailing list