daboide Commit
Revision 744
Date: 2007-01-09 11:40:08 -0800 (Tue, 09 Jan 2007)
Author: Paul
Changed:
U trunk/wizards/AppWizard/AppWizard.py
Log:
Fixed app wizard to produce valid classes when the table has spaces in it.
With this commit, your app will run instead of failing at startup. However,
it turns out that the sql manager in dCursorMixin doesn't properly quote
the table name when spaces are present, so at this time you can't run
queries.
Diff:
Modified: trunk/wizards/AppWizard/AppWizard.py
===================================================================
--- trunk/wizards/AppWizard/AppWizard.py 2007-01-09 14:36:17 UTC (rev
743)
+++ trunk/wizards/AppWizard/AppWizard.py 2007-01-09 19:40:08 UTC (rev
744)
@@ -850,7 +850,7 @@
if not os.path.exists(d):
os.mkdir(d)
- tableName = selTb[0].title()
+ tableName = selTb[0].title().replace(" ", "")
formOpenString = "\"Frm%s\" % form_name"
## Create the main script:
@@ -903,8 +903,9 @@
# Write each bizobj:
for table in selTb:
- bizImports.append(table.title())
- f = open("./%s.py" % table.title(), "w")
+ tableName = table.title().replace(" ", "")
+ bizImports.append(tableName)
+ f = open("./%s.py" % tableName, "w")
f.write(self.getBizobj(td, table))
f.close()
@@ -962,7 +963,7 @@
for table in selTb:
for classType in (("Frm", self.getForm),
("Grd", self.getGrd),
("PagEdit", self.getPagEdit),
("PagSelect", self.getPagSelect)):
- className = "%s%s" % (classType[0],
table.title())
+ className = "%s%s" % (classType[0],
table.title().replace(" ", ""))
uiImports.append(className)
f = open("./%s.py" % className, "w")
f.write(classType[1](table))
@@ -1004,7 +1005,7 @@
forms = ""
for table in tables:
forms = "".join((forms, """("%s",
app.ui.Frm%s),\n\t\t\t\t""" %
- (table.title(), table.title())))
+ (table.title(), table.title().replace(" ",
""))))
forms = "".join((forms, """("-", None),\n\t\t\t\t"""))
return open(os.path.join(self.wizDir,
"spec-MenFileOpen.py.txt")).read() % locals()
@@ -1016,7 +1017,7 @@
def getForm(self, table):
- tableName = table.title()
+ tableName = table.title().replace(" ", "")
if self.useFieldSpecs:
fieldSpecs = """
# Set up the field information for the form
@@ -1032,7 +1033,7 @@
def getGrd(self, table):
- tableName = table.title()
+ tableName = table.title().replace(" ", "")
colDefs = ""
if not self.useFieldSpecs:
# Manually set up the grid columns:
@@ -1041,24 +1042,21 @@
colDefs += """
# Delete or comment out any columns you don't want..."""
colSpec = """
- self.addColumn(dabo.ui.dColumn(self, DataField="%s",
DataType="%s",
- Caption="%s", Sortable=True,
Searchable=True, Editable=False))
+ self.addColumn(dabo.ui.dColumn(self, DataField="%s",
Caption="%s",
+ Sortable=True, Searchable=True, Editable=False))
"""
- sortedFieldNames = self.getSortedFieldNames( fieldDict )
- typeConversion = {"I" : "int", "C" : "char", "M" :
"memo", "D" : "date",
- "N" : "float", "F" : "float", "?" :
"char", "L" : "bool", "B" : "bool", "T" : "datetime"}
+ sortedFieldNames = self.getSortedFieldNames(fieldDict)
for tup in sortedFieldNames:
field = tup[1]
- typ =
typeConversion.get(fieldDict[field]["type"], "char")
- colDefs += colSpec % (field, typ, field)
+ colDefs += colSpec % (field, field.title())
return open(os.path.join(self.wizDir,
"spec-Grd.py.txt")).read() % locals()
def getPagEdit(self, table):
- tableName = table.title()
+ tableName = table.title().replace(" ", "")
createItems = ""
if not self.useFieldSpecs:
fieldDict = self.tableDict[table]["fields"]
@@ -1131,7 +1129,7 @@
def getPagSelect(self, table):
- tableName = table.title()
+ tableName = table.title().replace(" ", "")
selectOptionsPanel = ""
if not self.useFieldSpecs:
@@ -1257,7 +1255,7 @@
def getMain(self, dbConnectionDef, table):
- tableName = table.title()
+ tableName = table.title().replace(" ", "")
formOpenString = "\"Frm%s\" % form_name"
return open(os.path.join(self.wizDir,
"spec-main.py.txt")).read() % locals()
@@ -1318,7 +1316,7 @@
def getBizobj(self, tableDict, table):
- tableName = table.title()
+ tableName = table.title().replace(" ", "")
tbInfo = tableDict[table]
# find the pk field, if any:
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev