[Zope] sorry for lame question...

Tino Wildenhain tino@wildenhain.de
Mon, 27 Jan 2003 01:14:31 +0100


Hi Corey,

--On Sonntag, 26. Januar 2003 10:38 -0800 Corey Saltiel 
<corey@axcelerant.com> wrote:

>
> I'm completely new to Zope and am starting out with something I imagine
> is  amazingly simple - but after many attempts and perusals of docs and
> lists, I'm still unable to figure this one out...
>
>
> Using ZPT - how do I get the value returned from a ZSql method? This
> method only ever returns *one* value; I'd rather not do a tal:repeat if
> I'm able to.

Whats wrong with repeat here? repeat would give you if <yourmethod>
and variabe defining the same time. You can do it without repeat,
but it will be worser.

<span tal:repeat="foo here/your_ZSql_method" 
tal:content="foo/column">wopp</span>



> The best I can do is:
>
> <span tal:replace="here/my_ZSql_method">
>
>
> Which provides:
>
> "<Shared.DC.ZRDB.Results.Results instance at 0x8c6df8c>"

ZSQL method always return an object which behaves like a list
of zero or more objects which behave like an dictionary and
an object with attributes the same time (so you can write
result[index].column or result[index]['column']

>
> I don't want the instance - I want the value, of course.
>
> ( My lack of Python knowhow may make the obvious less so )
>
You should really really not hesiate to learn python any more :)
Just give the tutorial on python.org a try, it will clarify
much of your questions out.

Keep in mind: python does not bite. :)

>
> Also - could someone point me to the document(s) that explain or show an
> example of this? I was unable to find it explained anywhere.


> There's a ton of stuff on DTML - but I'm only interested in using ZPT
> wherever possible. Shouldn't the Zope Book ( I'm reading v. 2.6 ) try to
> use ZPT in all  it's standard examples rather than DTML?

I would like to see that too. But unfortunately...
>
> Why can't ZPT be used in other places, like ZSql methods? There is some

Guess why ;) Try to build up an example ;)

> serious confusion on where to use ZPT and where to use DTML. Why should a
> new user be required to learn *both* -- especialy when it's arguable that
> ZPT is more  "correct" ( in so far as much as better separation of logic
> from presentation, html/xml friendly, etc., etc. )
>
> I get the distinct impression from the zope-dev list that ZPT is,
> generaly, the  new desired replacement for DTML for most uses.

Um. The replacement consists of Python Scripts + ZPT, not ZPT allone.