def __setstate__(self, state): if _hasattribute(self, '__dict__'): _getattribute(self, '__dict__').clear() for name in self._p_gen_data_slots(): _delattribute(self, name) if state is not None: for key, value in iteritems(state): _setattribute(self, key, value)
def get(self, compute): """(compute) -> value Compute the value (if necessary) and return it. 'compute' needs to be a function that takes no arguments. """ # we are careful here not to mark object as UNSAVED if _hasattribute(self, 'value'): value = _getattribute(self, 'value') else: value = compute() _setattribute(self, 'value', value) return value
def __setattr__(self, name, value): if name[:3] != '_p_' and name not in _GHOST_SAFE_ATTRIBUTES: self._p_note_change() _setattribute(self, name, value)