[rhmessaging-commits] rhmessaging commits: r1335 - mgmt/mint.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Mon Nov 19 11:06:29 EST 2007
Author: nunofsantos
Date: 2007-11-19 11:06:28 -0500 (Mon, 19 Nov 2007)
New Revision: 1335
Modified:
mgmt/mint/schemaparser.py
Log:
generate multiple joins for reverse associations
Modified: mgmt/mint/schemaparser.py
===================================================================
--- mgmt/mint/schemaparser.py 2007-11-19 15:10:13 UTC (rev 1334)
+++ mgmt/mint/schemaparser.py 2007-11-19 16:06:28 UTC (rev 1335)
@@ -13,6 +13,7 @@
self.pythonOutput += "conn = connectionForURI(\"%s\")\n" % (self.options["dsn"])
self.pythonOutput += "sqlhub.processConnection = conn\n\n"
self.additional = ""
+ self.currentClass = ""
self.final = "\nclassToSchemaNameMap = dict()\n"
self.final += "schemaNameToClassMap = dict()\n"
# mapping between xml schema types and database column types
@@ -49,12 +50,17 @@
self.generateAttrib(name + "Low", type)
self.generateAttrib(name + "High", type)
+ def generateMultipleJoin(self, tableFrom, tableTo):
+ attrib = tableTo.lower() + "s"
+ self.additional += "\n%s.sqlmeta.addJoin(MultipleJoin('%s', joinMethodName='%s'))\n" % (tableFrom, tableTo, attrib)
+
def generateClassAttribs(self, schemaName, elements):
for elem in elements:
if (elem["@name"].endswith("Ref")):
reference = self.style.dbTableToPythonClass(elem["@name"]).replace("Ref", "")
attrib = reference[0].lower() + reference[1:]
self.generateForeignKeyAttrib(attrib, reference)
+ self.generateMultipleJoin(reference, self.currentClass)
elif (elem["@type"].startswith("hilo")):
self.generateHiLoAttrib(self.attrNameFromDbColumn(elem["@name"]), self.dataTypesMap[elem["@type"]])
else:
@@ -73,6 +79,7 @@
else:
pythonName = self.style.dbTableToPythonClass(schemaName)
statsPythonName = self.style.dbTableToPythonClass(schemaName + "_stats")
+ self.currentClass = pythonName
self.pythonOutput += "\nclass %s(SQLObject):\n" % (pythonName)
self.generateAttrib("idOriginal", "BigIntCol")
self.generateTimestampAttrib("rec")
@@ -115,6 +122,7 @@
self.additional = ""
if (self.pythonOutput.endswith("(SQLObject):\n")):
self.pythonOutput += " pass\n"
+ self.currentClass = ""
def parseConfigFile(self):
config = mllib.xml_parse("config.xml")
More information about the rhmessaging-commits
mailing list