Hi there, I created a Zclass that renders some data and displayes it. I use DTMLMethod as one of its base classes. One of the classes methods is called index_html. This method calls the rendering function. So http://..../myInstane works fine. However when I want to embed the output within an other page I either get the wrong output, or an error. using: <dtml-var myclass> produces just the content of the DTMLMetho (instead of rendering it first). <dtml-var expr="myclass.index_html()"> claimes that the rendering function I defined in the class are not defined. So how can I use my ZClass like a function, or how can I embed its output in an other page?? thanks Robert
So how can I use my ZClass like a function, or how can I embed its output in an other page??
Robert, I just went thru this myself. The zClass acts external folderish and therefore you have to acquire the zClass to render its methods (index_html or whatever). try <dtml-with yourzClass><dtml-var DTMLMethod></dtml-with> -Trevor
=> So how can I use my ZClass like a function, or how can I embed => its output in => an other page?? I am also new to all of this. So I may not be totally correct, but I dont think you can or should try to use a ZClass as a function. A ZClass is a template for an instance. All the methods/properties of a ZClass are only templates that become methods/properties of the instances that are created from that ZClass. If you want to create a function then you should create it as a method high up in the Zope Folder tree and it will then be acquired by all below it. You can do this as a DTML method or Python Script or any other object. You dont need to, and probably should not, use ZClasses for this task. Tom
Robert Rottermann writes:
I created a Zclass that renders some data and displayes it. I use DTMLMethod as one of its base classes. One of the classes methods is called index_html. This method calls the rendering function. So http://..../myInstane works fine. However when I want to embed the output within an other page I either get the wrong output, or an error.
using: <dtml-var myclass> produces just the content of the DTMLMetho (instead of rendering it first). Strange. Do not understand that....
<dtml-var expr="myclass.index_html()"> claimes that the rendering function I defined in the class are not defined. That's clear. Standard error, done hundreds of times....
"index_html" is a DTML Method, right? DTML Methods know about their context only if this information is passed explicitly! You call your "index_html" without any parameters. Hence, it does not know anything about its context. You may use: <dtml-var expr="myclass.index_html(myclass,_)"> You may read <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> to avoid standard errors.... Dieter
participants (4)
-
Dieter Maurer -
Robert Rottermann -
Tom Cameron -
Trevor Toenjes