[Zope] Re: Subclass and Image

Dieter Maurer dieter@handshake.de
Thu, 12 Jul 2001 18:35:48 +0200 (CEST)


drogahn@d.umn.edu writes:
 > ....
 > 3. <dtml-var testClassInstanceId> from another DTML method or 
 > document doesn't work!
 > 
 > It renders to (something like) <classname instance at 1234567>
 > I think that was when I used no base class
This is normal:

  "dtml-var" renders the object, if it is callable.
  Otherwise, it converts it into a string.

  Your instance object is apparently not callable.
  The "str" function, then, returns "<classname ....>".

 > ....
 > Now, when I use DTML Method as a base class it works, but dtml 
 > variables in the class index_html file aren't interpreted. eg they 
 > display as "&lt;dtml-var test&gt;"

Hmm:

  If you use "<dtml-var your_instance>", the "index_html"
  is irrelevant. Instead, you should get the rendered
  content of your DTML in the instance itself (it
  is a DTML Method, you told us!).

  If you use "<dtml-var "your_instance.index_html">",
  then the calling magic does not apply (because in a
  Python expression, i.e. inside "...", you take over
  full control -- no more magic!).
  The "str" applied to a DTML object returns the source html-quoted,
  as you described.

  To render "index_html", you should use:

     <dtml-var "_.render(your_instance.index_html)">




Dieter