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

2005-05-19 Thread Christer Fernstrom
- Original Message - 
From: "Cliff Ford" <[EMAIL PROTECTED]>
To: "Christer Fernstrom" <[EMAIL PROTECTED]>
Cc: 
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


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

2005-05-19 Thread Allen Schmidt
We noticed that also, but figured it was a problem on our part. We are on 2.7.5 
and have noticed this only on this version.
Very frustrating.
-Allen
Henk Laloli wrote:
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

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


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

2005-05-19 Thread Andreas Jung

--On Donnerstag, 19. Mai 2005 14:07 Uhr +0200 Henk Laloli 
<[EMAIL PROTECTED]> wrote:

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.
Fixed in Zope 2.7.7.
-aj

pgpzrVOWmYDr8.pgp
Description: PGP signature
___
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


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:


sqlquery:string



and corresponding dtml method:



...


-- 

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