Example #1
0
 def __getattr__(self, name):
     if name.startswith('_'):
         object.__getattribute__(self, name)
     else:
         try:
             return object.__getattribute__(self,
                                            '_dict')[_to_jsonc_name(name)]
         except KeyError:
             raise AttributeError('No member for %s or [\'%s\']' %
                                  (name, _to_jsonc_name(name)))
Example #2
0
 def __setattr__(self, attr, val):
     try:
         object.__getattribute__(self, attr)
         object.__setattr__(self, attr, val)
     except AttributeError as e:
         try:
             self._jsondata[attr] = val
         except KeyError as e:
             if six.PY2:
                 raise_from(AttributeError(e.message), e)
             else:
                 raise_from(AttributeError(e), e)
Example #3
0
 def __setattr__(self, attr, val):
     try:
         object.__getattribute__(self, attr)
         object.__setattr__(self, attr, val)
     except AttributeError as e:
         try:
             self._jsondata[attr] = val
         except KeyError as e:
             if six.PY2:
                 raise_from(AttributeError(e.message), e)
             else:
                 raise_from(AttributeError(e), e)
Example #4
0
 def __getattr__(self, attr):
     if object.__getattribute__(self, '_lazy'):
         #print("We're lazy instance!")
         if attr == 'code':  # Do not fetch full object if we're just getting the code
             return object.__getattribute__(self, '_jsondata')['code']
         f = object.__getattribute__(self, '_fetch_method')
         if f is not None:
             #print("Trying to fetch full one with %s" % f)
             new = f(object.__getattribute__(self, '_jsondata')['code'])
             self._jsondata = new._jsondata
             self._map_holvi_json_properties()
             self._lazy = False
         else:
             #print("No fetch method, giving up")
             pass
     return super(HolviObject, self).__getattr__(attr)
Example #5
0
 def __getattr__(self, attr):
     if object.__getattribute__(self, '_lazy'):
         #print("We're lazy instance!")
         if attr == 'code':  # Do not fetch full object if we're just getting the code
             return object.__getattribute__(self, '_jsondata')['code']
         f = object.__getattribute__(self, '_fetch_method')
         if f is not None:
             #print("Trying to fetch full one with %s" % f)
             new = f(object.__getattribute__(self, '_jsondata')['code'])
             self._jsondata = new._jsondata
             self._map_holvi_json_properties()
             self._lazy = False
         else:
             #print("No fetch method, giving up")
             pass
     return super(HolviObject, self).__getattr__(attr)
Example #6
0
    def __getattribute__(self, name):
        attr = object.__getattribute__(self, name)
        if name.startswith('_') or not callable(attr):
            return attr

        @lock
        def wrapper(*args, **kwargs):
            return attr(*args[1:], **kwargs)

        return wrapper
Example #7
0
    def __getattribute__(self, name):
        attr = object.__getattribute__(self, name)
        if name.startswith('_') or not callable(attr):
            return attr

        @lock
        def wrapper(*args, **kwargs):
            return attr(*args[1:], **kwargs)

        return wrapper
Example #8
0
 def __getattr__(self, attr):
     try:
         return object.__getattribute__(self, attr)
     except AttributeError as e:
         try:
             return self._jsondata[attr]
         except KeyError as e:
             if six.PY2:
                 raise_from(AttributeError(e.message), e)
             else:
                 raise_from(AttributeError(e), e)
Example #9
0
 def __getattr__(self, attr):
     try:
         return object.__getattribute__(self, attr)
     except AttributeError as e:
         try:
             return self._jsondata[attr]
         except KeyError as e:
             if six.PY2:
                 raise_from(AttributeError(e.message), e)
             else:
                 raise_from(AttributeError(e), e)
Example #10
0
 def __setattr__(self, name, value):
     if name.startswith('_'):
         object.__setattr__(self, name, value)
     else:
         object.__getattribute__(
             self, '_dict')[_to_jsonc_name(name)] = _convert_to_jsonc(value)