[Zope-dev] More on the getId issue...

Dieter Maurer dieter@handshake.de
Fri, 4 Jul 2003 20:50:47 +0200


Richard Jones wrote at 2003-7-1 12:03 +1000:
 > ...
 > PageTemplateFile (via Script and SimpleItem) inherits Item. This class 
 > has an attribute "id" set to '' by default. PageTemplateFiles don't use 
 > "id" though, they use __name__. The getId implementation that 
 > PageTemplateFiles use has some mention of __name__ in it, but it'll 
 > never get used because:
 > 
 >      id = ''
 >      def getId(self):
 >          name=getattr(self, 'id', None)
 >          if callable(name):
 >              return name()
 >          if name is not None:
 >              return name
 >          if hasattr(self, '__name__'):
 >              return self.__name__
 >          raise AttributeError, 'This object has no id'

This is funny code indeed...

   Obviously, the code starting with line 4 in the function
   can only be executed by hackers.

Please file a bug report.


Dieter