[Zope] still problem with dtml-with

Jerome Alet alet@librelogiciel.com
Thu, 25 Jul 2002 11:32:49 +0200


On Thu, Jul 25, 2002 at 09:43:37AM +0100, Toby Dickenson wrote:
> On Thursday 25 Jul 2002 9:18 am, Jerome Alet wrote:
> 
> If you need <dtml-var x> to give a string prestentation of the object, and 
> <dtml-with x> to give you access to the object's properties (rather than 
> those of the string) then x needs a __str__

OK, now it really works like I wanted it to work :

        index_html  ==> renders as HTML
        <dtml-with> ==> access to the object's methods and properties
        <dtml-var obj> ==> same as index_html
        
For those who might be interested, I've just defined a __str__ method
which renders my object as HTML, then defined an index_html method
which just returns str(self), and no need for a __call__ method.

> Another option is to add a method which returns the string, so you have to 
> render it as <dtml-var myinstance fmt=mymethod>.

No, I wanted to keep it simple to use

> You havent really explained that this class is, and what behaviour you want 
> from these different operations, so its hard to give overall good advice.

Yours was very good !

Thank you

Jerome Alet