def __get__(self, instance, owner=None): if instance is None: return self value = self.get_uninherited(instance, owner) if self.inheritable and rec_getattr(instance, self.inherit_flag, False): value = rec_getattr(instance, self.inherit_from, value) return value
def __set__(self, instance, value): action = rec_getattr(instance, self.set_action_name, None) assert callable( action ), "The action in a SetActionMixin (%s) should be callable!" % self.label if self.set_action_before: action() super(SetActionMixin, self).__set__(instance, value) if not self.set_action_before: action()
def __get__(self, instance, owner=None): if instance is None: return self action = rec_getattr(instance, self.get_action_name, None) assert callable(action), "The action in a GetActionMixin (%s) should be callable!" % self.label if self.get_action_after: action() value = super(GetActionMixin, self).__get__(instance, owner=owner) if not self.get_action_after: action() return value
def __get__(self, instance, owner=None): if instance is None: return self action = rec_getattr(instance, self.get_action_name, None) assert callable( action ), "The action in a GetActionMixin (%s) should be callable!" % self.label if self.get_action_after: action() value = super(GetActionMixin, self).__get__(instance, owner=owner) if not self.get_action_after: action() return value
def update_matrices(self, model): for i, (inp, check) in enumerate(zip(self.i_inputs, self.i_checks)): prop = self.props[i] inp.set_value(getattr(model, prop.label)) if prop.inherit_flag is not None: # Set checkbox sensitivity: inh_from = rec_getattr(model, prop.inherit_flag, None) check.set_sensitive(not inh_from is None) # Set checkbox state: inh_value = getattr(model, prop.inherit_flag) check.set_active(inh_value) # Set inherit value sensitivity inp.set_sensitive(not inh_value) elif check is not None: check.set_senstive(False)
def __set__(self, instance, value): signal = rec_getattr(instance, self.signal_name, None) if signal is not None: # Get the old value old = getattr(instance, self.label) with signal.ignore(): super(SignalMixin, self).__set__(instance, value) # Get the new value new = getattr(instance, self.label) # Check if we're dealing with some special class (in case we # emit the signal anyway) or immutables (in case we only emit # when the value has changed) if isinstance(old, observables.ObsWrapperBase) or old != new: signal.emit() else: super(SignalMixin, self).__set__(instance, value)
def __set__(self, instance, value): action = rec_getattr(instance, self.set_action_name, None) assert callable(action), "The action in a SetActionMixin (%s) should be callable!" % self.label if self.set_action_before: action() super(SetActionMixin, self).__set__(instance, value) if not self.set_action_before: action()
def _get(self, instance): """ Private getter """ return rec_getattr(instance, self._get_private_label(), self.default)