[PEAK] I don't understand uponAssembly()
John Landahl
john at landahl.org
Thu Mar 24 17:25:02 EST 2005
Doug Quale wrote:
> I want to run some initialization when the component instance is
> created. (The components are controllers for GUI views.) Normally
> that would be done in __init__(), but peak largely removes the need to
> code __init__, and for that I'm grateful.
I would say that rather than largely removing the need for __init__,
PEAK removes it completely. There's never a reason to write an __init__
method for a PEAK component as far as I know.
> class k(binding.Component):
> def _my_init(self):
> ...
> _my_init = binding.Make(_my_init, uponAssembly=True)
If you look around the PEAK codebase you'll see that Phillip typically
names these sort of "startup" routines "__onStart". Whatever you call
them, you may want to consider using a double underscore prefix for
these so they'll be harder to call by accident.
- John
More information about the PEAK
mailing list