def _e_attrholder(self, instance, init_attr = None): res = instance.transient_state #e or other kind of stateplace # init the default val if needed. if init_attr: attr = init_attr # we need to init the default value for attr, if it's not already defined. ####e OPTIM: this hasattr might be slow (or even buggy, tho i think it'll work # by raising an exception that's a subclass of AttributeError; the slow part is computing args for that every time) if not hasattr(res, attr): val = self._e_eval_defaultValue(attr, instance) #k should I just do setattr(res, attr, val), or is there something special and better about this: ## set_default_attrs(res, {attr : val}) ##k arg syntax set_default_attrs(res, **{attr : val}) # print_compact_stack( "\ndid set_default_attrs of %r, %r, %r: " % (res,attr,val)) val0 = getattr(res, attr) ## assert val is val0, if not (val is val0): print "bug: set_default_attrs should have stored %r at %r in %r, but it has %r" % (val, attr, res, val0) pass return res
def _init_instance(self): super(World, self)._init_instance() set_default_attrs(self.untracked_model_state, _index_counter=4000 ) #070213; could State() do this for us instead? #e
def _init_instance(self): super(LocalVariable_StateRef, self)._init_instance() set_default_attrs( self.transient_state, value=self.defaultValue) #e should coerce that to self.type
def _init_instance(self): super(LocalVariable_StateRef, self)._init_instance() set_default_attrs( self.transient_state, value = self.defaultValue) #e should coerce that to self.type
def _init_instance(self): super(ToggleShow, self)._init_instance() set_default_attrs( self.transient_state, open = True)
def _init_instance(self): super(World, self)._init_instance() set_default_attrs( self.untracked_model_state, _index_counter = 4000) #070213; could State() do this for us instead? #e