Altering values from HTML forms before SQL insert
I have a HTML form that returns a value that I need to alter before I pass it to a SQLMethod. To do this I created I've assumed I should use either dtml-with or dtml-let to create a new variable with my desired value and then call the SQL MEthod within the dtml-with. Some sample code is as follows. SQLMethod: ID:odbcInsertTalk arguments: LocationAndTime Query: insert into talk (LocationAndTime) values ( <dtml-sqlvar LocationAndTime type=string> ) DTML Document: <dtml-var standard_html_header> <dtml-with "_.namespace(LocationAndTime=Location+'--now')"> <dtml-comment> <dtml-call odbcInsertTalk> </dtml-comment> <ul> <li>Location: [<dtml-var LocationAndTime>] </ul> </dtml-with> <dtml-var standard_html_footer> I get my desired values for LocationAndTime for the code as shown however, if I uncomment <dtml-call odbcInsertTalk> then I get a complaint Error Type: Bad Request Error Value: ['LocationAndTime'] odbcInsertTalk works fine when I test directly from the SQLMethod manager page. I t also works if I remove the <dtml-with> and change the HTML form to send the exact name (of course this does not have the value I want but it does get correctly added to the DB) I'm using ODBC DA version ZODBCDA-3.1.0b2-win32-x86.tgz. Zope version: Zope 2.1.4 (binary release, python 1.5.2, win32-x86) Python version: 1.5.2 (#0, Jul 30 1999, 09:52:18) [MSC 32 bit (Intel)] System Platform: win32 Process ID: 217 (264) Running for: 3 hours 24 min 35 sec Any help would be very apprecitated. Neil Bartlett
On Thu, 17 Feb 2000, Neil Bartlett wrote:
I have a HTML form that returns a value that I need to alter before I pass it to a SQLMethod.
To do this I created I've assumed I should use either dtml-with or dtml-let to create a new variable with my desired value and then call the SQL MEthod within the dtml-with.
[snip]
DTML Document:
<dtml-var standard_html_header> <dtml-with "_.namespace(LocationAndTime=Location+'--now')"> <dtml-comment> <dtml-call odbcInsertTalk> </dtml-comment> <ul> <li>Location: [<dtml-var LocationAndTime>] </ul> </dtml-with> <dtml-var standard_html_footer>
I would try: <dtml-var standard_html_header> <dtml-call expr="REQUEST.set('LocationAndTime', Location + '--now')"> <dtml-call odbcInsertTalk> <ul> <li>Location: [<dtml-var LocationAndTime>] </ul> <dtml-var standard_html_footer>
I get my desired values for LocationAndTime for the code as shown however, if I uncomment <dtml-call odbcInsertTalk> then I get a complaint
This makes sense; modifications to the namespace through dtml-let and/or _.namespace() are local to that DTML Document/Method only. To persistently modify the namespace, you have to use REQUEST.set().
Any help would be very apprecitated.
Hope this helps.
Neil Bartlett
--Jeff --- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.com/
Thanks Jeff - not only does it makes sense it works! Hadn't realized that dtml-let and dtml-with were only scoped at the current level. Is there a syntax for saying set value at this and nested levels but do not persist? (More curious than have a need!) Neil
-----Original Message----- From: Jeff K. Hoffman [mailto:jeff@goingv.com] Sent: Thursday, February 17, 2000 3:07 PM To: Neil Bartlett Cc: zope@zope.org Subject: Re: [Zope] Altering values from HTML forms before SQL insert
On Thu, 17 Feb 2000, Neil Bartlett wrote:
I have a HTML form that returns a value that I need to alter before I pass it to a SQLMethod.
To do this I created I've assumed I should use either dtml-with or dtml-let to create a new variable with my desired value and then call the SQL MEthod within the dtml-with.
[snip]
DTML Document:
<dtml-var standard_html_header> <dtml-with "_.namespace(LocationAndTime=Location+'--now')"> <dtml-comment> <dtml-call odbcInsertTalk> </dtml-comment> <ul> <li>Location: [<dtml-var LocationAndTime>] </ul> </dtml-with> <dtml-var standard_html_footer>
I would try:
<dtml-var standard_html_header>
<dtml-call expr="REQUEST.set('LocationAndTime', Location + '--now')"> <dtml-call odbcInsertTalk> <ul> <li>Location: [<dtml-var LocationAndTime>] </ul>
<dtml-var standard_html_footer>
I get my desired values for LocationAndTime for the code as shown however, if I uncomment <dtml-call odbcInsertTalk> then I get a complaint
This makes sense; modifications to the namespace through dtml-let and/or _.namespace() are local to that DTML Document/Method only. To persistently modify the namespace, you have to use REQUEST.set().
Any help would be very apprecitated.
Hope this helps.
Neil Bartlett
--Jeff
--- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.com/
On Thu, 17 Feb 2000, Neil Bartlett wrote:
Thanks Jeff - not only does it makes sense it works! Hadn't realized that dtml-let and dtml-with were only scoped at the current level.
Glad it works.
Is there a syntax for saying set value at this and nested levels but do not persist? (More curious than have a need!)
Not that I know of. There are ways to achieve this, I'm sure, but not with a single tag. The values put into the REQUEST using REQUEST.set() are only valid for the lifetime of that single request, for that single user, so you shouldn't step on your own toes that much. Of course, there are times when this might be required, but I'd look at my design and see if there's not another way to do things.
Neil
--Jeff --- Jeff K. Hoffman 704.849.0731 x108 Chief Technology Officer mailto:jeff@goingv.com Going Virtual, L.L.C. http://www.goingv.com/
participants (2)
-
Jeff K. Hoffman -
Neil Bartlett