[Zope] Calling a Z SQL Method

Tino Wildenhain tino at wildenhain.de
Thu Jan 27 10:56:45 EST 2005


On Thu, 2005-01-27 at 10:43 -0500, Asad Habib wrote:
> I have a Z SQL method that contains a simple SELECT statement and takes
> no arguments. When I call this Z SQL method from a DTML document/method I
> use the following: <dtml-in retrieve_names_sql></dtml-in>
> 
> This works just fine.
> 
> However, when I place the Z SQL method inside a Folder called selects and
> then use the following, I get an error:
> <dtml-in "selects.retrieve_names_sql"></dtml-in>
> 
> The error I get is the following:
> KeyError: 0
> 
> On the other hand, when I use the following I do not get an error:
> <dtml-in "selects.retrieve_names_sql()"></dtml-in>
> I understand the difference between the 2 <dtml-in> statements but why
> isit that I have to explicitly show that retrieve_names_sql does not take
> any arguments in the latter case and not the former. The id of this Z SQL
> method/Zope object is retrieve_names_sql and it seems to me that this
> should be recognized within the object hierarchy. Any help/input would be
> greatly appreciated. Thank you.

<dtml-XXX blah> is equivalent to <dtml-XXX name="blah">
and does some magic tricks to find out if the object
identified by name is callable, and if so how, and then
it is used as ordinary attribute or called via ()
or with some default arguments (REQUEST, Namespace etc)

<dtml-XXX "blah"> and <dtml-XXX expr="blah">
are equivalent also and expect the contents 
beeing a valid python expression, that is, 
you cant simply use . and - in names (since
they have a meaning in python expressions)
and you have to write the call explicit if
you have a method or function. Otoh, this
offers you the way to call the function with
arguments.

Regards
Tino



More information about the Zope mailing list