Calling parent class method when method is overridden in current class?
Hi all, I'm in the process of creating a Python based product, and have a need to call the base classes index_html method. My problem is that I need to call it from my classes index_html. My class has DTMLDocument as the base class so I want to call something like DTMLDocument.index_html(). This is my classes index_html (which by the way does not do as I want, obviously or I wouldn't be posting this 8¬)): def index_html(self,REQUEST,RESPONSE): """ this is a doc string """ xml=self.inheritedAttribute(xmlRenderer,'index_html') # this is where I want to call DTMLDocument's index_html() xsl=getattr(self,'style.xsl',None) if xsl is None: xsl=open(INSTANCE_HOME+'/lib/python/Products/xmlRenderer/style.xsl','r').rea d() else: xsl=xsl.document_src(REQUEST,RESPONSE) RESPONSE.setHeader('content-type','text/html; charset=UTF-8') return Sablot.ProcessStrings(xsl,xml) The reason for wanting to do this is so I can get any DTML rendered before I do my stuff with the results. Which by the way means that I'll stick it through a XSL processor with an associated stylesheet and get HTML back. Any ideas? tia Phil phil.harris@zope.co.uk
Phil Harris wrote:
Hi all,
I'm in the process of creating a Python based product, and have a need to call the base classes index_html method.
My problem is that I need to call it from my classes index_html.
My class has DTMLDocument as the base class so I want to call something like DTMLDocument.index_html().
Perhaps DTMLDocument.index_html(self) ? The only problem is if you need to call a base-class method from a derived ZClass. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
Steve, I'm pretty sure I've tried that but I'll try it again and see what happens, hang on I'll be right back. Right I'm back, I thought I'd tried it and I had, I get this error: Error Type: TypeError Error Value: call of non-function (type None) Traceback (innermost last): File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\Publish.py, line 222, in publish_module File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\Publish.py, line 187, in publish File D:\ZOPE_2~1.2_D\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: 1_introd.xml) File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\Publish.py, line 171, in publish File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: index_html) File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: index_html) File D:\zope_2.2_dev\lib\python\Products\xmlRenderer\xmlRender.py, line 58, in index_html (Object: 1_introd.xml) TypeError: (see above) which seems to be telling me that DTMLDocument.index_html is None, weird eh! TFT (thanks for trying) Phil Phil.harris@zope.co.uk ----- Original Message ----- From: "Steve Alexander" <steve@cat-box.net> To: "Phil Harris" <phil.harris@zope.co.uk> Cc: "Zope-Dev@Zope. Org" <zope-dev@zope.org> Sent: Thursday, August 03, 2000 9:40 AM Subject: Re: [Zope-dev] Calling parent class method when method is overridden in current class?
Phil Harris wrote:
Hi all,
I'm in the process of creating a Python based product, and have a need
to
call the base classes index_html method.
My problem is that I need to call it from my classes index_html.
My class has DTMLDocument as the base class so I want to call something like DTMLDocument.index_html().
Perhaps DTMLDocument.index_html(self) ?
The only problem is if you need to call a base-class method from a derived ZClass.
-- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
Yay, Solved it! I just had to call __call__ from the DTMLDocument and bob is now married to my mothers sister. Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Phil Harris" <phil.harris@zope.co.uk> To: "Steve Alexander" <steve@cat-box.net> Cc: "Zope-Dev@Zope. Org" <zope-dev@zope.org> Sent: Thursday, August 03, 2000 9:45 AM Subject: Re: [Zope-dev] Calling parent class method when method is overridden in current class?
Steve,
I'm pretty sure I've tried that but I'll try it again and see what happens, hang on I'll be right back.
Right I'm back, I thought I'd tried it and I had, I get this error:
Error Type: TypeError Error Value: call of non-function (type None)
Traceback (innermost last): File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\Publish.py, line 222, in publish_module File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\Publish.py, line 187, in publish File D:\ZOPE_2~1.2_D\lib\python\Zope\__init__.py, line 221, in zpublisher_exception_hook (Object: 1_introd.xml) File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\Publish.py, line 171, in publish File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\mapply.py, line 160, in mapply (Object: index_html) File D:\ZOPE_2~1.2_D\lib\python\ZPublisher\Publish.py, line 112, in call_object (Object: index_html) File D:\zope_2.2_dev\lib\python\Products\xmlRenderer\xmlRender.py, line 58, in index_html (Object: 1_introd.xml) TypeError: (see above)
which seems to be telling me that DTMLDocument.index_html is None, weird eh!
TFT (thanks for trying)
Phil Phil.harris@zope.co.uk
----- Original Message ----- From: "Steve Alexander" <steve@cat-box.net> To: "Phil Harris" <phil.harris@zope.co.uk> Cc: "Zope-Dev@Zope. Org" <zope-dev@zope.org> Sent: Thursday, August 03, 2000 9:40 AM Subject: Re: [Zope-dev] Calling parent class method when method is overridden in current class?
Phil Harris wrote:
Hi all,
I'm in the process of creating a Python based product, and have a need
to
call the base classes index_html method.
My problem is that I need to call it from my classes index_html.
My class has DTMLDocument as the base class so I want to call something like DTMLDocument.index_html().
Perhaps DTMLDocument.index_html(self) ?
The only problem is if you need to call a base-class method from a derived ZClass.
-- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
participants (2)
-
Phil Harris -
Steve Alexander