[ZDP] Zopebook - Comment on Chapter 12

Peter Looyenga peter@catslair.org
Sat, 19 Apr 2003 01:31:13 +0200


Hi !

Well, this is the second attempt. I hope you managed to alter the site
to give the new email adress (even though it will be a lot more quiet in
the old situation ;-)).


I recently started working with Zope and right now I'm in the process of
evaluating it for an upcoming project to find out if it will do
everything we need. By doing so I'm also heavily studying the
documentation and so far the Zope book helped me out a lot. So today I
tried adding some comments but to no avail. That (and Martijn's
redirection) is how I ended up here ;-)

Chapter 12 has a paragraph about passing arguments to zsql methods but
doesn't go any further than using the Z search interface even though it
mentions direct usage. I only wanted to use dhtml and decided to write
it up because the process confused me. You can also access this on
www.zope.org/Members/Lion-O/zsql. Hope this helps you out some more.
There will be more where this came from since I tend to write up my
experiences for future reference. If I can help you guys with some of
them it'll be my pleasure.

Anyway, here's my addition I tried to add to the Zopebook (Chapter 12,
the end of 'passing arguments):

Its nice that you explained how to use the Z Search interface but
although you can do it manully this too can be tricky. IMO even more
than using the zsearch method. So I feel this is missing from the
manual:

Although you can't call a zsql method directly from a form its still
quite easy to make your own input interface manually. You will need to
call a dhtml method (or document, but I haven't tested this) which in
its turn will call the zsql method. There is a bit more to this then
simply calling the z sql method and be done with it. Allthough you can
use <dhtml-call expr3D"<script>(parameter1, parameter2, ... )"> when
calling a Python script this doesn't work for zsql methods. Instead you
will have to provide the names of the parameters you configured in the
zsql method and set the value manually while calling it. I found this to
be a little confusing myself..

For example: suppose you have a zsql method called AddEntry which needs
2 parameters called "nick" and "comment" (both strings). You have setup
an input form (dhtml method) which has 2 text input fields called
"guest_name" and "opinion" and as said above it calls another dhtml
method called addEntryAction which processes the data. Now, to tell
addEntryAction to call AddEntry I was tempted to use <dhtml-call
expr="AddEntry(guest_name, opinion)"> but zsql methods don't work this
way. Instead you'll need <dhtml-call expr="AddEntry(nick=guest_name,
comment=opinion)"> and now you can use a zsql method without the use of
a z search interface.

-- 
With kind regards,

Peter Looyenga

.\\ PGP/GPG key: http://www.catslair.org/pubkey.asc