Re: [Zope-DB] Retrieving Data from Z SQL in Python

2005-05-19 Thread Cliff Ford
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
___
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db


Re: [Zope-DB] ZPTs and database accesses

2005-05-19 Thread Jaroslav Lukesh
Dne tvrtek, 28. dubna 2005 20:17 Andreas Jung [EMAIL PROTECTED] 
napsal(a):
 You have not read the book correctly. First statement just said that you
 can't SQL queries using ZPT. In Zope you specify SQL queries using
 *ZSQL methods* that use DTML as markup language...this is not the same
 as defining SQL inside DTML methods/documents or Page Templates.

with discuss about security it is possible to query sql directly from dtml/zpt 
with yourZSQLmethod like this:

param
sqlquery:string
/params
dtml-var sqlquery

and corresponding dtml method:

dtml-call REQUEST.set('sqlquery','select * from table')
dtml-in yourZSQLmethod
...
/dtml-in

-- 

Jaroslav Lukesh
  ---
  This e-mail can not contain any viruses because I use Linux

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


[Zope-DB] key error on query variable in previous and next batches

2005-05-19 Thread Henk Laloli
Inside the code generated by the zope search interface dtml result page

a batch variable 'query' is used in Zope 2.7.6. This gives a key error

when having next and previous batches. It also seems to be used in the 

ZSQL methods query template because the same error occurs there when 
having more than 20 results (the batch value).  Does anybody know about

this? In the dtml template it is easy to change, but I can't do much 
about the ZSQL template.

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