[Zope-CMF] Re: Five views / redirects

yuppie y.2005- at wcm-solutions.de
Tue Oct 18 07:04:57 EDT 2005


Victor Safronovich wrote:
> Hello Chris Withers,
> 
> Tuesday, October 18, 2005, 4:24:29 PM, you wrote:
> 
> CW> yuppie wrote:
>>>     def __call__(self):
>>>         if self.isTuesday():
>>>             return ZopeTwoPageTemplateFile('tuesday.pt').__of__(self)()
>>>         return self.index()
>>>
> 
> CW> Surely the following is going to be better?
> 
> CW>       tuesday_pt = ZopeTwoPageTemplateFile('tuesday.pt')
> 
> CW>       def __call__(self):
> CW>           if self.isTuesday():
> CW>               return self.tuesday_pt.__of__(self)()
>               IMO __of__(self) is not needing now.
> 

Yes. Both modifications make sense. This is much faster and nicer code::

     tuesday_pt = ZopeTwoPageTemplateFile('tuesday.pt')

     def __call__(self):
         if self.isTuesday():
             return self.tuesday_pt()
         return self.index()


Cheers,

	Yuppie




More information about the Zope-CMF mailing list