[ZPT] Re: ZPT in Python products, and _setName

Shane Hathaway shane@zope.com
Mon, 15 Oct 2001 13:07:06 -0400


Steve Alexander wrote:

> Steve Alexander wrote:
> 
>>
>>
>> *** PageTemplateFile.py.original
>> --- ./PageTemplateFile.py.new
>> ***************
>> *** 130,135 ****
>> --- 130,139 ----
>>           self.__name__ = name
>>           self.filename = filename = os.path.join(_prefix, filename + 
>> '.zpt')
>>
>> +     def _setName(self, name):
>> +         self.__name__ = name
>> +         self._need__name__ = 0
>> +
>>       def pt_getContext(self):
>>           root = self.getPhysicalRoot()
>>           c = {'template': self,
> 
> 
> 
> Looking more closely at PageTemplateFile, I can dispense with the need 
> for _setName in the circumstances described earlier if I just insert 
> this line in the __init__ method:
> 
>   self._need__name__ = 0

Then the page template file might have the wrong name, which leads to 
security declarations not working.  Page template files *do* need a name 
and there can't be ambiguity.  In today's Zope, that is. :-)  Your first 
patch will work.

Shane