[Zope] index_html method in a zclass

Amos Latteier amos@aracnet.com
Sat, 11 Sep 1999 14:33:17 -0700


At 10:26 PM 9/11/99 -0100, Sture Lygren wrote:
>I've just created a simple zclass that contains an index_html method. I've
also
>created a test instance of the class. I tought calling the instance using
>'<!--#var instancename-->' from a dtml method or document would render the 
>class' index_html method, but I get no output. 

This will not do what you want.

>The only way I can display the instance' index_html is by dooing:
>'<!--#with instancename--><!--#var index_html--><!--#/with-->' 

This is the correct way to do what you want.

This situation can be a little confusing. We know that when you publish an
object via a URL, Zope will call the object's 'index_html' if it has one.
So why can't you do the same thing in DTML?

The answer is that calling an object in DTML is not the same thing as
publishing an object with a URL.

For example, <dtml-var myFolder> will not call the Folder's 'index_html'
method. Instead the DTML 'var' tag calls an object using the '__call__'
method.

For more information on DTML subtleties see the DTML User's Guide and this
How-To:

  http://www.zope.org:18200/Documentation/How-To/AdvancedDTML

Good luck!

-Amos