Skip to content

Commit

Permalink
disabled buggy storage of attributes in redis. this is getting fixed …
Browse files Browse the repository at this point in the history
…in 1.0
  • Loading branch information
adpham95 authored Mar 7, 2019
1 parent 9c25252 commit 9838e34
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,29 @@ def __setstate__(self, state):
self.__dict__.update(state)
self.__dict__['_cache'] = make_cache(walkoff.config.Config.CACHE)

def __getattribute__(self, item):
try:
return object.__getattribute__(self, item)
except AttributeError:
key = self._format_cache_key(item)
if not self._cache.exists(key):
raise AttributeError
else:
obj = self._cache.get(key)
return dill.loads(obj)

def __setattr__(self, key, value):
if key in _reserved_fields:
self.__dict__[key] = value
elif key.startswith('__') and key.endswith('__'):
super(App, self).__setattr__(key, value)
else:
value = dill.dumps(value)
key = self._format_cache_key(key)
self._cache.set(key, value)
# def __getattribute__(self, item):
# try:
# return object.__getattribute__(self, item)
# except AttributeError:
# key = self._format_cache_key(item)
# if not self._cache.exists(key):
# raise AttributeError
# else:
# obj = self._cache.get(key)
# return dill.loads(obj)

# def __setattr__(self, key, value):
# if key in _reserved_fields:
# self.__dict__[key] = value
# elif key.startswith('__') and key.endswith('__'):
# super(App, self).__setattr__(key, value)
# else:
# value = dill.dumps(value)
# key = self._format_cache_key(key)
# self._cache.set(key, value)

@classmethod
def from_cache(cls, app, device, context):
base = App(app, device, context)
base.__class__ = cls
return base
return base

0 comments on commit 9838e34

Please sign in to comment.