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,8 +20,7 @@ class TroveboxObject(object):
|
|||
def _set_fields(self, json_dict):
|
||||
""" Set this object's attributes specified in json_dict """
|
||||
for key, value in json_dict.items():
|
||||
if key.startswith("_"):
|
||||
raise ValueError("Illegal attribute: %s" % key)
|
||||
if not key.startswith("_"):
|
||||
setattr(self, key, value)
|
||||
|
||||
def _replace_fields(self, json_dict):
|
||||
|
@ -30,6 +29,7 @@ class TroveboxObject(object):
|
|||
those in json_dict.
|
||||
"""
|
||||
for key in self._json_dict.keys():
|
||||
if not key.startswith("_"):
|
||||
delattr(self, key)
|
||||
self._json_dict = json_dict
|
||||
self._set_fields(json_dict)
|
||||
|
@ -39,6 +39,7 @@ class TroveboxObject(object):
|
|||
Delete this object's attributes, including name and id
|
||||
"""
|
||||
for key in self._json_dict.keys():
|
||||
if not key.startswith("_"):
|
||||
delattr(self, key)
|
||||
self._json_dict = {}
|
||||
self.id = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue