Implement ConfigItem via getattr, setattr overrides
@dguest, to avoid mucking about with ConfigItem.__dict__
, I went even more gnarly. See just the last commit.
It's mostly as an exercise because I could believe this is more screwed up than I am aware of...
There are 3 elements:
- We want
__getattr__
to accessself._data
for all_data
's attributes, but we have to avoid infinite recursion when retrieving_data
. - We want
__setattr__
to permit setting_data
once only, so_initialised
is a bit of a fake attribute (also not visible fromkeys()
). - We need to override
deepcopy
so that it doesn't hit the_initialised
block on setting_data
.
Edited by Teng Jian Khoo