[Zope-DB] Hello!

Charlie Clark charlie@begeistert.org
Mon, 21 Jul 2003 19:37:24 +0200


On 2003-07-21 at 18:37:45 [+0200], Philip Kilner wrote:
> OK - so ZPT calls script, script calls ZSQL Method?

Yes.

> Well, I understand what you're saying - but it's a little dispiriting to 
> find that the gulf between DTML and ZPT is getting wider rahther than 
> narrower, and that there is in effect an even larger amoubnt of "missing" 
> documentation as a result.

Enter the world of the great divide between the knights that say "ni" 
(embedded application logic in presentation logic is convenient) and those 
that say "ni ni ni" (mixing application logic and presentation logic causes 
big problems sooner or later). If you want to do the first, use DTML or 
PHP. If you want to do the second stay with ZPT. For the fun of it Google 
for "PHP is evil"...

A programming language is just so much better at the banal data 
manipulation you need than a presentation description language. And 
templates are everybody's way out of the programatically generated HTML 
nightmares.

ZPT makes is easier for me to understand when what I'm doing is 
presentation or application and realise that the distinction is sometimes 
difficult.

> > No TALES or METAL required. However, this will fail as insertBook 
> > expects a Python dictionary and not an http-request - this is also a 
> > security feature, by the way.
> > 
 
> Ahh - actually, I'd "understood" that Zope presented the request object 
> /as/ a dictionary, and hence expected things to be a little more 
> "automatic" than they really are...

Because with what you call the "request object". This a special thing in 
Zope and not at all the same as an http-request. The request object is 
dictionary like but that's not the issue. And too much magic is bad for 
you. The form's action will be called directly by the browser and must be 
able not only to deal with the request but also to return something. This 
is not possible for an ZSQL-method. It could be possible to call the 
PageTemplate again and depending on the existence of special variable call 
a ZSQL-Method, I guess but don't go there.
 
> > You call an ZSQL-method within Zope like this:
> > r = context.selectBook()
> > 
> > in ZPT this looks like this <span tal:define="r 
> > here/selectBook"></span> unless you wish to pass a parameter to the 
> > method in which case you have to use Python syntax, ie.
> > <span tal:define="r python: here.selectBook(ISBN=1)"></span>

> Can I ask why you have designated this "r"?
I generally abbreviate in my scripts, particularly for throwaway variables 
like the one above. "results" is convention for the results object of any 
ZSQL-query but sometimes I confuse myself when I have lots of "results" in 
anyone page.
 
> I /think/ so - I'll come back to you after I have plodded through 
> it...<smile>

Plug it in, test it and come back to me with soot on your face and 
electrified hair! ;-)

Charlie