Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not callable(getattr(self,attr))
and type(object.__getattribute__(self,attr)) == Attribute
and issubclass(object.__getattribute__(self,attr).value_type,DataMessage) == True
and object.__getattribute__(self,attr).nested == True
and object.__getattribute__(self,attr).mapping != None
and object.__getattribute__(self,attr).name != 'id'
and not attr.startswith("__")}
for attr in nested:
if nested[attr].name in message['relationships']:
val = message['relationships'][nested[attr].name]['data']
if isinstance(val,(list,tuple)):
val_list = []
for v in val:
val_list.append(DataMessage.from_message(json.dumps({'data':v}),object.__getattribute__(self,attr).value_type))
setattr(self,attr,val_list)
else:
setattr(self,attr,DataMessage.from_message(json.dumps(val),object.__getattribute__(self,attr).value_type))
setattr(nested[attr],'updated',True) #mark this attribute as updated for later updating the backend object
else:
if nested[attr].required == True:
janus_logger.error('Missing required field ' + str(nested[attr].name) + ".")
raise Exception('Missing required field ' + str(nested[attr].name) + ".")
if 'relationships' in message:
#get relationships
relations = {attr:object.__getattribute__(self,attr)
for attr in dir(self)
if not callable(getattr(self,attr))