[Zope-dev] More on the getId issue...
Richard Jones
richard@commonground.com.au
Sat, 5 Jul 2003 10:53:37 +1000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Saturday, July 5, 2003, at 04:50 AM, Dieter Maurer wrote:
> 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.
Or I could just fix it with the modified version I posted :)
Richard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (Darwin)
iD8DBQE/BiGSrGisBEHG6TARAqEbAJ405Vv/bmCRwRygT1pOAv0CxsEd3gCfZGc6
WQOJT0xo3TElzmeU1gRLLkk=
=eYtw
-----END PGP SIGNATURE-----