----- Original Message ----- From: "Cliff Ford" <[EMAIL PROTECTED]>
To: "Christer Fernstrom" <[EMAIL PROTECTED]>
Cc: <zope-db@zope.org>
Sent: Thursday, May 19, 2005 8:16 AM
Subject: Re: [Zope-DB] Retrieving Data from Z SQL in Python




Christer Fernstrom wrote:
Hello,

I have a very simple Z SQL method that works fine when I test run it. But
when I call it from a Python script (see below) and attempt to print the
result, I get the following error:

Error Type: TypeError
Error Value: cannot concatenate 'str' and 'ImplicitAcquirerWrapper' objects


------ Python script -----
# Import a standard function, and get the HTML request and response objects.
##from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE = request.RESPONSE


data = context.getChunk1()
for data_row in data:
 print "data-row="+data_row
return printed

You need to iterate over the columns in the row:

data = context.getChunk1()
for data_row in data:
  print "data-row="
  for item in data_row:
    print item + ' '
return printed

It is more normal to fetch one result row at a time:

for data_row in context.getChunk1():
    # and handle the results by column name
    print data_row.FirstName
    print ' '
    print data_row.Surname
    ...
return printed

HTH

Cliff


Thanks Cliff. What you propose works fine! -- christer

_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db

Reply via email to