[Zope] DTML string in Zope Product

Max M maxm@mxm.dk
Wed, 09 Oct 2002 19:36:56 +0200


Bo M. Maryniuck wrote:
 > On Wednesday 09 October 2002 15:46, Max M wrote:
 >
 >>######
 >>from Globals import HTML
 >>class SomeClass:
 >>     someFoo = HTML('<standard_html_header>Test!<standard_html_footer>')
 >>#####
 >
 >
 > Errm... Be exact. Perhaps this way:
 >
 > from Globals import HTML
 > class SomeClass:
 > 	def foo(self, REQUEST = None):
 > 		"""blah"""
 > 		someFoo = HTML('<standard_html_header>Test!<standard_html_footer>')
 > 		return someFoo(self, self.REQUEST)

Well that depends on what you are trying to do. The way you are doing it 
you compile somFoo every time it is used. You should at least make it a 
class attribute:

from Globals import HTML
class SomeClass:
     someFoo = HTML('<standard_html_header>Test!<standard_html_footer>')
     def foo(self, REQUEST = None):
         """blah"""
         return self.someFoo(self, self.REQUEST)

But then you could just as well call it "foo" and bypass the ekstra 
function call:

from Globals import HTML
class SomeClass:
     foo = HTML('<standard_html_header>Test!<standard_html_footer>')

And then we are back where we started ;-)

regards Max M

 ><evolve>
   >    >