Don't set/replace/delete TroveboxObject attributes that start with an underscore.
Just ignore them, don't raise an exception
This commit is contained in:
parent
ed5cc0ac11
commit
cfa2f40e7e
1 changed files with 6 additions and 5 deletions
|
@ -20,9 +20,8 @@ class TroveboxObject(object):
|
||||||
def _set_fields(self, json_dict):
|
def _set_fields(self, json_dict):
|
||||||
""" Set this object's attributes specified in json_dict """
|
""" Set this object's attributes specified in json_dict """
|
||||||
for key, value in json_dict.items():
|
for key, value in json_dict.items():
|
||||||
if key.startswith("_"):
|
if not key.startswith("_"):
|
||||||
raise ValueError("Illegal attribute: %s" % key)
|
setattr(self, key, value)
|
||||||
setattr(self, key, value)
|
|
||||||
|
|
||||||
def _replace_fields(self, json_dict):
|
def _replace_fields(self, json_dict):
|
||||||
"""
|
"""
|
||||||
|
@ -30,7 +29,8 @@ class TroveboxObject(object):
|
||||||
those in json_dict.
|
those in json_dict.
|
||||||
"""
|
"""
|
||||||
for key in self._json_dict.keys():
|
for key in self._json_dict.keys():
|
||||||
delattr(self, key)
|
if not key.startswith("_"):
|
||||||
|
delattr(self, key)
|
||||||
self._json_dict = json_dict
|
self._json_dict = json_dict
|
||||||
self._set_fields(json_dict)
|
self._set_fields(json_dict)
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@ class TroveboxObject(object):
|
||||||
Delete this object's attributes, including name and id
|
Delete this object's attributes, including name and id
|
||||||
"""
|
"""
|
||||||
for key in self._json_dict.keys():
|
for key in self._json_dict.keys():
|
||||||
delattr(self, key)
|
if not key.startswith("_"):
|
||||||
|
delattr(self, key)
|
||||||
self._json_dict = {}
|
self._json_dict = {}
|
||||||
self.id = None
|
self.id = None
|
||||||
self.name = None
|
self.name = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue