Hi I am a Newbie to zope. I am interested in working in zope and have been involved in work related with Pythonscripts and PostgreSql and Page Templates. I have become stuck at a point and I am not able to find what to do next. I am using a python Script to run a ZSQL method and then the values are to be sent to the Page Template to be displayed.The Script is: from Products.PythonScripts.standard import html_quote r = context.ond.db.zqll_clin # this is a zsql method in a different folder at root for x in r: print x['Id'],x['Name'],x['tt'] # these are the fields of the table return r The error message I get is Error Type: KeyError Error Value: 0 Am i not being able to get the record set from the database?Because if I give a print command in the loop it does not work.HEnce it may not be entering the loop.What is the method to access a Zsql Method which is another folder? If there is someone who could help me out here it would be very helpful.Since i am stuck with this problem for 2 days and I have tried other possibilities. Regards John Kunchandy --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.380 / Virus Database: 213 - Release Date: 7/24/2002
zope wrote:
Hi
I am a Newbie to zope. I am interested in working in zope and have been involved in work related with Pythonscripts and PostgreSql and Page Templates. I have become stuck at a point and I am not able to find what to do next. I am using a python Script to run a ZSQL method and then the values are to be sent to the Page Template to be displayed.The Script is:
from Products.PythonScripts.standard import html_quote r = context.ond.db.zqll_clin # this is a zsql method in a different folder at root
John I think you should be *calling* the method here: r = context.ond.db.zqll_clin() If you do not need to pass parameters, it may work. Otherwise, you should get a different error that is easier to figure out. -- Jim Washington
On Fri, Jul 26, 2002 at 08:56:07AM +0530, zope wrote:
from Products.PythonScripts.standard import html_quote r = context.ond.db.zqll_clin # this is a zsql method in a different folder at root for x in r: print x['Id'],x['Name'],x['tt'] # these are the fields of the table return r
The error message I get is Error Type: KeyError Error Value: 0
Just a guess, but what happens if you change the script to just: r=context.ond.db.zqll_clin print r ? If you get a result something like "<ZSQL Method at 0xfd234908ce>", then you're not actually calling the method, and just referencing it. If that's the case, try changing the lines to: r=context.ond.db.zqll_clin() print r and see if you get a list back. If that works, then you should be ready to tackle the loop. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of zope Sent: Thursday, July 25, 2002 11:26 PM To: zope@zope.org Subject: [Zope] Newbie to Zope Hi I am a Newbie to zope. I am interested in working in zope and have been involved in work related with Pythonscripts and PostgreSql and Page Templates. I have become stuck at a point and I am not able to find what to do next. I am using a python Script to run a ZSQL method and then the values are to be sent to the Page Template to be displayed.The Script is: from Products.PythonScripts.standard import html_quote r = context.ond.db.zqll_clin # this is a zsql method in a different folder at root for x in r: print x['Id'],x['Name'],x['tt'] # these are the fields of the table return r The error message I get is Error Type: KeyError Error Value: 0 Am i not being able to get the record set from the database?Because if I give a print command in the loop it does not work.HEnce it may not be entering the loop.What is the method to access a Zsql Method which is another folder? If there is someone who could help me out here it would be very helpful.Since i am stuck with this problem for 2 days and I have tried other possibilities. John -- You have *call* the ZSQLMethod, which you're not doing. You're just referencing it. Try: r = context.ond.db.zqll_clin() (note the parens for the call at the end) BTW, why are you going from ZSQLMethod -> PythonScript -> PageTemplate? In most cases, the ZSQLMethod returns data that you can just iterate over and display directly in the PageTemplate; in cases where you want to clean up the data, using a PluggableBrain is usually a cleaner option than iterating and creating a new list in a PythonScript. Search the list or The Zope Book for info on PluggableBrains. - J.
participants (4)
-
Jim Washington -
Joel Burton -
Mike Renfro -
zope