Prakash’s Blog

Innovation Explored

Prakash’s Blog header image 2

ZPT] ZPT and ZSQL Methods

July 15th, 2004 · No Comments

This is easy,
create the following objects. You can fold them into two (one form and
one zsql method) but it is a bit easier to “see” what happens with 4:

- a ZSQL Method sqlGetNames (that *must* use dtml) with two parameters
firstname, lastname you use to construct a query.
- a form getusers_form with two input fields named
firstname, lastname and and action called getnames
- a python script named getnames that gets two parameters firstname,
lastname
- an outputform named showusers that presents the result in a table

Here is a sketch of the four objects:

#———————-
# sqlGetNames
# parameters :
# firstname. lastname
#———————-
select firstname. lastname from tblEmployee
where firstname. like +’%’
and lastname like + ‘%’;

#———————-
# getusers_form
#———————-

#———————-
# getnames
# parameters :
# firstname. lastname
#———————-
users = context.sqlGetNames(firstname=firstname, lastname=lastname)
return context.showusers(users=users)

#———————-
# show_form
#———————-

   

I have included ein “realworld” example where everyting is folded into a
single form (input, call to ZSQL Method and Output)
The used ZSQL Method and its parameters are paste in as comment.

Robert

Joao Paulo Liberato wrote:
> Hi everybody,
>
> I have a very basic question. I’m starting with Zope, and I’d like to
> grab some data from a MySQL database.
> The DA for MySQL was installed without any problem, and I could connect
> to my database.
> I was reading the Zope Book, chapter 18 - Relational Database
> Connectivity, and all examples were given using DTML.
> But I don’t want to use dtml. Hence, I’d like to know how can I use ZPT
> to call a ZSQL method, passing parameters to it, and how to process
> those parameters within the ZSQL Method.
> Can anyone provide me a basic example of how to do it?
>
> Thanks in advance,
>
> Joao Paulo.
> _______________________________________________
> ZPT mailing list
> ZPT@zope.org
> http://mail.zope.org/mailman/listinfo/zpt
>
>

Tags: Zope

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment