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:
sneakypete81 2013-10-29 09:31:38 +00:00
parent ed5cc0ac11
commit cfa2f40e7e

View file

@ -20,8 +20,7 @@ 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,6 +29,7 @@ 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():
if not key.startswith("_"):
delattr(self, key) delattr(self, key)
self._json_dict = json_dict self._json_dict = json_dict
self._set_fields(json_dict) self._set_fields(json_dict)
@ -39,6 +39,7 @@ 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():
if not key.startswith("_"):
delattr(self, key) delattr(self, key)
self._json_dict = {} self._json_dict = {}
self.id = None self.id = None