Пример #1
0
 def __setattr__(self, attr, value):
     self.__dict__[attr] = jassign(
         self.__dict__.get(
             attr,
             Unassigned("variable '%s' in %s" %
                        (attr, self._jeeves_funcname))), value,
         self.__dict__['_jeeves_base_env'])
Пример #2
0
 def __setattr__(self, name, value):
     field_names = [field.name for field in self._meta.concrete_fields
                    ] if hasattr(self, '_meta') else []
     if name in field_names and name not in ('jeeves_vars', 'jeeves_id',
                                             'id'):
         old_val = getattr(self, name) if hasattr(self, name) else \
                     Unassigned("attribute '%s' in %s" % (name, self.__class__.__name__))
         models.Model.__setattr__(
             self, name,
             JeevesLib.jassign(old_val, value, self.jeeves_base_env))
     else:
         models.Model.__setattr__(self, name, value)
Пример #3
0
 def __setattr__(self, name, value):
     """
     Sets an attribute for a Jeeves model.
     TODO: Figure out how we can make this faster.
     """
     field_names = [field.name for field in self._meta.concrete_fields] \
                     if hasattr(self, '_meta') else []
     if name in field_names and \
         name not in ('jeeves_vars', 'jeeves_id', 'id'):
         old_val = getattr(self, name) if hasattr(self, name) else \
                     Unassigned("attribute '%s' in %s" % \
                         (name, self.__class__.__name__))
         models.Model.__setattr__(
             self, name,
             JeevesLib.jassign(old_val, value, self.jeeves_base_env))
     else:
         models.Model.__setattr__(self, name, value)
Пример #4
0
def jgetitem(obj, item):
    try:
        return obj[item]
    except (KeyError, KeyError, TypeError) as e:
        return Unassigned("item '%s'" % attr)
Пример #5
0
def jgetattr(obj, attr):
    if isinstance(obj, FExpr):
        return getattr(obj, attr)
    else:
        return getattr(obj, attr) if hasattr(obj, attr) else Unassigned(
            "attribute '%s'" % attr)