I'm a Zope beginner. I'm trying to create an ImageTemplate ZClass. This will work
similar to an Image, but the user can insert it directly in DTML using <dtml-var 
and it will get expanded into HTML (with formatting, <img> tag, caption, etc.)
This may be long and complicated, but I thought that #4 below was interesting
because it demonstrates how to get at base class methods even if you have
overridden them.

OK, here's the situation:
1. I created a ZClass derived from Image. 
2. I overloaded the index_html to add spit out some HTML instead of the image.
3. If I call an instance of the ZClass directly I get the expected results. 
    The index_html is called and I get back some HTML.
4. To get to the image I created an External Method that calls the index_html
    method of the my base class (Image):
    # I create an External Method called IMG that calls this Python method:
    def super_index_html (self):
             for classy in self.__class__.__bases__:
                     if classy.__name__ == 'Image':
                             return classy.index_html (self, self.REQUEST,\

So far, so good!

Now all I want to do is insert my ZClass in some DTML. Here's what happens:
1. I try to insert in instance of my ZClass into a DTML Method using:
    <dtml-var gato>
2. The Publisher does not call the view method (index_html) of the object!
Instead it calls str() which is __str__ in Image and that calls Image.tag().
I can't overload __str__ because Zope does not allow a method to start
with _ underscore.

I ran this in the debugger, Publish.publish() (line 173) has this code:
         if result is not response: response.setBody(result)
This is where the trouble begins. setBody() calls str() function on the object.

How do I insert my ZClass into DTML now?


Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to