Question about Python with Zope/ZSQL
I have, a question about using python with zope/zsql methods and wondered if anyone might be able to offer some advice. I have a python script called: addNewSurvey which, before adding a new record to a database, checks for two things: an existing surveyid and an existing listenerid both of which are colums in the same 'surveys' table. I have two python scripts: checkforsurvey(suveryid) and checkforlistener(listenerid) each of which which, on their own, successfully return a string of 'true' if a duplicate value exists. My problem, and my question, arises in the in the addNewSurvey script (see attached). What might be wrong with my syntax in addNewSurvey that is preventing me from adding a record successuflly? There are no error messages when it runs, but no visible results either? Any suggestions you might have are appreciated. John Tynan - webmaster KJZZ.org / KBAQ.or 480.774.8462
Hi John, the addNewSurvey.py you attached is hopefully not the script you run. It has more bugs then will fit in one mail. The main functionality is in a function that is never called, the function has several return statements on the same call level. Even a nested function with an identical name defined. Probably you were looking for something like: test = context.checkforsurvey(surveyid=surveyid) true = 'true' if test == true: return 'redirect' target = '../duplicatesurvey' return context.REQUEST.RESPONSE.redirect(target) else: test2 = context.checkforlistener(listenerid=listenerid) if test2 == true: context.sqlAddSurvey(surveyid=surveyid, listenerid=listenerid, region=region, firstname=firstname, lastname=lastname, updates=updates, question01=question01, question02=question02, question03=question03, question04=question04, question05=question05, question06=question06, question07=question07, question08=question08, question09=question09, question10=question10, question11=question11, completed=completed) target = '../calls/newcall?surveyid=' + surveyid context.REQUEST.RESPONSE.redirect(target) else: target = '../duplicatesurvey' context.REQUEST.RESPONSE.redirect(target) Ulrich -- ------------------------------------------------------------ Relevant Traffic AB, Riddargatan 10, 11435 Stockholm, Sweden Tel. +46-8-6789750 http://www.relevanttraffic.se
participants (2)
-
John Tynan -
Ulrich Wisser