Greetings Zope Mentors... I am of a grave realization that perhaps I am once again banging my head on a brick wall. I am the one, some may remember, that is using PostgreSQL for data collection and writing dtml forms for administration of articles that can be pulled from one data source for multiple locations in my website. My last problem was in reference of pulling a checkbox value into a dtml page. Now, with all of that working, my problem is writing back to the table with the updated information on an article. Below is my list of trial and errors: * I have verified that up to the dtml method of collecting the proper information. * I have tried, in my dtml method of posting to the database, all different ways of collecting the data to be written. (this is where my data fails to post to the tables) Because in my reading of other emails that are posting to Zope, as much info as possible is what is requested, so here are 2 dtml methods where I am seeing the failures - no error pages are displayed, it just tells me it was not successful writing. 1st method, where all changed information to the article is gathered. Data checks are preformed before the following code - seeing if the checkbox is set to 1 or 0... <<DTML Method -updateArticle_html>> <!-- START OF WRITING INFO TO TABLE IN POSTGRESQL --> <dtml-try> <dtml-call "article1_updateRecord( a1_Title=_['newtitle'], a1_Author=_['newauthor'], a1_Body=_['newbody'], a1_Pix1=_['newpix1'], a1_Pix2=_['newpix2'], a1_Date=_['newdate'], ai1=_['newmain'], ai2=_['newstate'], ai3=_['newmesc'], ai4=_['newcorp'], ai5=_['newgsa'], ai6=_['newreseller'], ai8=_['newnetapp'], ai9=_['newmobile'], ai10=_['neweducation'], a1_Publish=_['newpublish'], a1_IDNum=_['newarticle'])"> <dtml-call "REQUEST.set('status', 'ok')"> <dtml-except> <dtml-call "REQUEST.set('status', 'failed')"> </dtml-try> <dtml-if "_['status']=='ok'"> <h1>Record was sucessfully Updated.</h1> <form action="index_html"> <input type="submit" value="OK"> </form> <dtml-else> <h1>Updating the new record failed.<br>No record was changed.</h1> <table> <tr> <td> <form action="update_article_html"> <input type="submit" value="Try Again"> </form> </td> <td> <form action="index_html"> <input type="submit" value="OK"> </form> </td> </tr> </table> </dtml-if> -------------------------- The *dtml-call "article1_updateRecord* calls the following ZSql method: <<Arguments:>> A1_Title A1_Author A1_Body A1_Pix1 A1_Pix2 A1_Date Ai1 Ai2 Ai3 Ai4 Ai5 Ai6 Ai8 Ai9 Ai10 A1_Publish A1_IDNum <<SQL statement:>> UPDATE A1 SET A1_Title=<dtml-sqlvar a1_Title type="string">, A1_Author=<dtml-sqlvar a1_Author type="string">, A1_Body=<dtml-sqlvar a1_Body type="string">, A1_Pix1=<dtml-sqlvar a1_Pix1 type="string">, A1_Pix2=<dtml-sqlvar a1_Pix2 type="string">, A1_Date=<dtml-sqlvar a1_Date type="string">, Ai1=<dtml-sqlvar ai1 type="string">, Ai2=<dtml-sqlvar ai2 type="string">, Ai3=<dtml-sqlvar ai3 type="string">, Ai4=<dtml-sqlvar ai4 type="string">, Ai5=<dtml-sqlvar ai5 type="string">, Ai6=<dtml-sqlvar ai6 type="string">, Ai8=<dtml-sqlvar ai8 type="string">, Ai9=<dtml-sqlvar ai9 type="string">, Ai10=<dtml-sqlvar ai10 type="string">, A1_Publish=<dtml-sqlvar a1_Publish type="string"> WHERE A1_IDNum=<dtml-sqlvar a1_IDNum type="string"> ------------------------- ** all items in the table are set to "string" - so I am writing Strings to the db. I have tested this method with '<dtml...>' and all other ways that are suggested by all the different documentation I have read about zope. This is the only way I have been able to write data to the db table when adding, so slight modification for Updates seem rational. *sigh* where am I getting this wrong? Does anyone have ideas? Don Brooksby
<<SQL statement:>>
UPDATE A1 SET A1_Title=<dtml-sqlvar a1_Title type="string">, A quick guess... what about not quoting type="string", e.g.
A1_Title=<dtml-sqlvar a1_Title type=string> Have you read http://www.zope.org/Members/jshell/ZSQLMethods-InsertingData ? PieterB
On Wed, Feb 12, 2003 at 01:14:53PM -0700, Don Brooksby wrote:
Because in my reading of other emails that are posting to Zope, as much info as possible is what is requested, so here are 2 dtml methods where I am seeing the failures - no error pages are displayed, it just tells me it was not successful writing.
That's because you caught the errors in <dtml-try>...<dtml-except>...</dtml-try>. Test it again with ONLY the <dtml-call> that actually updates the table; in particular get rid of the tags I mentioned. That way you'll get a traceback with more information. Come back and post the traceback and maybe somebody can help you. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's MARMITE ACTION HERO LEATHER GLOVE! (random hero from isometric.spaceninja.com)
----- Original Message ----- From: "Paul Winkler" <pw_lists@slinkp.com> To: <zope@zope.org> Sent: Wednesday, February 12, 2003 9:58 PM Subject: Re: [Zope] Content Management
On Wed, Feb 12, 2003 at 01:14:53PM -0700, Don Brooksby wrote:
Because in my reading of other emails that are posting to Zope, as much info as possible is what is requested, so here are 2 dtml methods where I am seeing the failures - no error pages are displayed, it just tells me it was not successful writing.
That's because you caught the errors in <dtml-try>...<dtml-except>...</dtml-try>.
Test it again with ONLY the <dtml-call> that actually updates the table; in particular get rid of the tags I mentioned.
That way you'll get a traceback with more information. Come back and post the traceback and maybe somebody can help you.
Also, Don, you really don't want to use DTML for that kind of stuff. Better to direct the posting of the form to a pythons script ("Script (Python)" as they are called in the ZMI) and then generate error messages form there and then either redirecting to or calling a DTML-method to report errors/success. Doing all that in DTML is way to hard to be worth the effort - been there, done that - and you'll be able to write code that traps errors in a much nicer way than you can do in DTML - and as a bonus you will find that yopur code will easier to write and debug. My 2 <insert lowly currency here> worth. /dario - -------------------------------------------------------------------- Dario Lopez-Kästen, IT Systems & Services Chalmers University of Tech.
participants (4)
-
Dario Lopez-Kästen -
Don Brooksby -
Paul Winkler -
PieterB