=?iso-8859-1?Q?Re:_[Zope-CMF]_New_Product,
_=5F=5Fgetattr=5F=5F_and_dtml-in?=
samuzeau@oreka.com
samuzeau at oreka.com
Tue Sep 14 06:03:34 EDT 2004
Hi Dieter,
OK, evrything works fine. Thank you.
Sincerily
PS
>I have a new product under CMF1.3/Zope2.6.0
>
>This produtc is a new Specific Type.
>In that one I have in my class:
>
>...
>def __getattr__(self, attrname ):
>if attrname == 'attrib':
>return functionlamdba()
>else:
>return getattr(self,attrname)
It is *VERY* difficult to implement a safe "__getattr__".
Therefore, you should only try when there is no other way.
Your use case can very easily be solved with an "ComputedAttribute":
from ComputedAttribute import ComputedAttribute
class YourClass(...):
...
attrib = ComputedAttribute(functionlambda)
...
No need for the difficult "__getattr__"...
--
Dieter
Cordialement
PS
////////////////////////////////////////////////////////////
// Webmail Oreka : http://www.oreka.com
////////////////////////////////////////////////////////////
More information about the Zope-CMF
mailing list