示例#1
0
 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
示例#2
0
 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
示例#3
0
 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()
示例#4
0
 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
示例#5
0
 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
示例#6
0
文件: views.py 项目: fbocches/PyXRD
 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)
示例#7
0
 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)
示例#8
0
 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)
示例#9
0
 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)
示例#10
0
 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()
示例#11
0
 def _get(self, instance):
     """ Private getter """
     return rec_getattr(instance, self._get_private_label(), self.default)
示例#12
0
 def _get(self, instance):
     """ Private getter """
     return rec_getattr(instance, self._get_private_label(), self.default)