[rhmessaging-commits] rhmessaging commits: r2418 - mgmt/trunk/mint/python/mint.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Sep 5 11:44:05 EDT 2008


Author: nunofsantos
Date: 2008-09-05 11:44:05 -0400 (Fri, 05 Sep 2008)
New Revision: 2418

Modified:
   mgmt/trunk/mint/python/mint/__init__.py
   mgmt/trunk/mint/python/mint/schemaparser.py
   mgmt/trunk/mint/python/mint/update.py
Log:
handle 2-part id

Modified: mgmt/trunk/mint/python/mint/__init__.py
===================================================================
--- mgmt/trunk/mint/python/mint/__init__.py	2008-09-05 15:00:30 UTC (rev 2417)
+++ mgmt/trunk/mint/python/mint/__init__.py	2008-09-05 15:44:05 UTC (rev 2418)
@@ -150,14 +150,14 @@
     self.mchan = None
 
   def getObject(self, cls, id):
-    id = id.second # XXX new id hack
+    compositeId = "%s:%s" % (id.first, id.second)
 
     try:
-      obj = self.objectsById[id]
+      obj = self.objectsById[compositeId]
     except KeyError:
       try:
-        obj = cls.selectBy(idOriginal=id, managedBroker=self.id)[0]
-        self.objectsById[id] = obj
+        obj = cls.selectBy(idSourceScope=id.first, idSourceObject=id.second, managedBroker=self.id)[0]
+        self.objectsById[compositeId] = obj
       except IndexError:
         raise ObjectNotFound()
 

Modified: mgmt/trunk/mint/python/mint/schemaparser.py
===================================================================
--- mgmt/trunk/mint/python/mint/schemaparser.py	2008-09-05 15:00:30 UTC (rev 2417)
+++ mgmt/trunk/mint/python/mint/schemaparser.py	2008-09-05 15:44:05 UTC (rev 2418)
@@ -91,20 +91,16 @@
     for elem in elements:
       elemName = self.renameReservedWord(elem["@name"])
       if (elem["@type"] == "objId"):
-        if (elemName.endswith("Ref")):
-          reference = elem["@references"]
-          # handle cases where the referenced class is in a different namespace (ie, contains a ".")
-          namespaceIndex = reference.find(".")
-          if (namespaceIndex > 0):
-            reference = reference[namespaceIndex + 1:]
-          reference = self.style.dbTableToPythonClass(reference)
-          reference = self.renameReservedWord(reference)
-          attrib = reference[0].lower() + reference[1:]
-          self.generateForeignKeyAttrib(attrib, reference)
-          self.generateMultipleJoin(reference, self.currentClass)
-        else:
-          # if reference doesn't have a "Ref" prefix, handle as a large uint
-          self.generateAttrib(self.attrNameFromDbColumn(elemName), self.dataTypesMap["uint64"])
+        reference = elem["@references"]
+        # handle cases where the referenced class is in a different namespace (ie, contains a ".")
+        namespaceIndex = reference.find(".")
+        if (namespaceIndex > 0):
+          reference = reference[namespaceIndex + 1:]
+        reference = self.style.dbTableToPythonClass(reference)
+        reference = self.renameReservedWord(reference)
+        attrib = reference[0].lower() + reference[1:]
+        self.generateForeignKeyAttrib(attrib, reference)
+        self.generateMultipleJoin(reference, self.currentClass)
       elif (elem["@type"].startswith("hilo")):
         self.generateHiLoAttrib(self.attrNameFromDbColumn(elemName), self.dataTypesMap[elem["@type"]])
       elif (elem["@type"].startswith("mma")):
@@ -131,12 +127,13 @@
     self.currentClass = pythonName
     self.pythonOutput += "\nclass %s(SQLObject):\n" % (pythonName)
     self.generateLazyUpdate()
-    self.generateAttrib("idOriginal", "BigIntCol")
     self.generateTimestampAttrib("rec")
     if (stats):
       self.generateForeignKeyAttrib(colPythonName[0].lower() + colPythonName[1:], keyPythonName)
       self.generateMultipleJoin(origPythonName, pythonName, "stats")
     else:
+      self.generateAttrib("idSourceScope", "BigIntCol")
+      self.generateAttrib("idSourceObject", "BigIntCol")
       self.generateTimestampAttrib("creation")
       self.generateTimestampAttrib("deletion")
       self.generateAttrib("managedBroker", "StringCol", "length=1000")

Modified: mgmt/trunk/mint/python/mint/update.py
===================================================================
--- mgmt/trunk/mint/python/mint/update.py	2008-09-05 15:00:30 UTC (rev 2417)
+++ mgmt/trunk/mint/python/mint/update.py	2008-09-05 15:44:05 UTC (rev 2418)
@@ -68,9 +68,10 @@
 
 def processAttributes(conn, attrs, cls):
   if "id" in attrs:
-    # XXX new id hack
-    idorig = attrs.pop("id").second
-    attrs["idOriginal"] = idorig
+    id = attrs.pop("id")
+    if (not cls.__name__.endswith("Stats")):
+      attrs["idSourceScope"] = id.first
+      attrs["idSourceObject"] = id.second
 
   if "connectionRef" in attrs:
     attrs["clientConnectionRef"] = attrs.pop("connectionRef")
@@ -153,7 +154,6 @@
     attrs = dict(self.props)
 
     id = attrs["id"]
-
     processAttributes(self.conn, attrs, cls)
 
     # XXX move these down to the try/except




More information about the rhmessaging-commits mailing list