[Zope-dev] Patch for PSQL Input Wizard
Bill Anderson
bill.anderson@immortalitysystems.net
Thu, 06 Jan 2000 00:16:20 -0700
This is a multi-part message in MIME format.
--------------1EDA37988C72205E5EEE32B5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello, whilst working with the newly updated SQL Input Wizard, I came
across a problem, and an annoyance.
This time, I have a patch in the form of a (Unified) diff.
This diff contains two changes:
o Old syntax replaced with new syntax
o Changed the way the fields are named.
Specifically, on the second change, I modified it so that instead of
"TableName.Field" the variables are "TableName_Field". Th ereason being
that if you use this as a starting point for more complicarted forms,
you will find yourself rewriting them.
For example:
If you can't do this in your db code:
<dtml-if "TableName.Field==12">
...
</dtml-if>
As it will return a Name error on "TableName".
There are other issues too, involving setting REQUEST variables, but
they are all resolved by the "TableName_Field" format ... AFAIK.
Bill Anderson
--
In flying I have learned that carelessness and overconfidence are
usually far more dangerous than deliberately accepted risks.
-- Wilbur Wright in a letter to his father, September 1900
--------------1EDA37988C72205E5EEE32B5
Content-Type: text/html; charset=us-ascii;
name="Wizard.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Wizard.diff"
--- Wizard.py.old Thu Jan 6 00:07:11 2000
+++ Wizard.py Wed Jan 5 21:18:14 2000
@@ -172,23 +172,23 @@
def _uniqueCol(self, table, column):
#return table + string.capitalize(column)
- return table + '.' + column
+ return table + '_' + column
def _buildInputForm(self, resultPageId):
#base %s parameters: result page id, form contents
- base = """<!--#var standard_html_header-->
-<H2><!--#var title_or_id--> <!--#var document_title--></H2>
+ base = """<dtml-var standard_html_header>
+<H2><dtml-var title_or_id> <dtml-var document_title></H2>
<P><FORM ACTION="%s" METHOD="POST">
-<TABLE>
+<table>
%s
-</TABLE>
+</table>
<input type="SUBMIT" name="submit" value="Insert">
</FORM>
-<!--#var standard_html_footer-->"""
- inputBase = '\t<TR><TD ALIGN="RIGHT">%s</TD><TD><INPUT TYPE="TEXT" NAME="%s"></TD></TR>'
+<dtml-var standard_html_footer>"""
+ inputBase = '\t<tr><td ALIGN="RIGHT">%s</td><td><INPUT TYPE="TEXT" NAME="%s"></td></tr>'
form = []
for i in self.selectedColumns:
- form.append('<TR BGCOLOR="#CCCCCC"><TD COLSPAN=2>%s</TD></TR>'
+ form.append('<tr BGCOLOR="#CCCCCC"><td COLSPAN=2>%s</td></tr>'
% i.tableName)
for j in i.columns:
if j in i.optional:
@@ -204,11 +204,11 @@
return base % (resultPageId, string.join(form, '\n'))
def _buildResultPage(self, sqlMethodId):
- base = """<!--#var standard_html_header-->
-<H2><!--#var title_or_id--> <!--#var document_title--></H2>
-<P><!--#call "%s(REQUEST)"-->
+ base = """<dtml-var standard_html_header>
+<H2><dtml-var title_or_id> <dtml-var document_title></H2>
+<P><dtml-call "%s(REQUEST)">
Your data was inserted in the Database!
-<!--#var standard_html_footer-->""" # How do I catch SQL errors?
+<dtml-var standard_html_footer>""" # How do I catch SQL errors?
return base % sqlMethodId
def debug(self):
@@ -220,7 +220,7 @@
return x
def _buildSQLValues(self, table, nonOptCol):
- template = '<!--#sqlvar %s type=%s %s-->'
+ template = '<dtml-sqlvar %s type=%s %s>'
args = []
for i in table.columns:
tp = self.info.type(table.tableName, i)
@@ -229,7 +229,7 @@
oneArg = template % (uniqueCol, tp, opt) + ','
if i in table.optional:
- args.append('<!--#if %s-->\n\t\t\t%s\n\t\t<!--#/if-->'
+ args.append('<dtml-if %s>\n\t\t\t%s\n\t\t</dtml-if>'
% (uniqueCol, oneArg))
else:
args.append(oneArg)
@@ -250,7 +250,7 @@
newCol = []
for i in range(len(table.columns)):
if table.columns[i] in table.optional:
- newCol.append('<!--#if %s -->\n\t\t%s\n\t<!--#/if-->' %
+ newCol.append('<dtml-if %s -->\n\t\t%s\n\t</dtml-if>' %
(self._uniqueCol(table.tableName,
table.columns[i]),
tempCols[i]))
@@ -286,7 +286,7 @@
self._buildSQLInto(i, nonOptCol),
self._buildSQLValues(i, nonOptCol)))
- return string.join(inputArgs), string.join(command,'\n<!--#var sql_delimiter -->\n')
+ return string.join(inputArgs), string.join(command,'\n<dtml-var sql_delimiter >\n')
def getObjectsInfo(self, REQUEST):
--------------1EDA37988C72205E5EEE32B5--