Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#raise Exception('Return value has to be instance of JanusResponse')
janus_logger.info("Not a JanusResponse. Will return this as it is. No mapping.")
return response_obj
message = None
#caching
loaded_from_cache = False
if self.cached_get_hook != None:
cached_object = self.cached_get_hook(response_obj)
if cached_object != None:
loaded_from_cache = True
message = cached_object #returned cached, already mapped, response
janus_logger.info("Will return cached message: " + str(loaded_from_cache))
if loaded_from_cache == False: #nothing in cache or cache deactivated
self.message = response_obj.message #get the message type to return
obj = response_obj.data #get the data to return
data = DataMessage.from_object(obj,self.message,do_nesting=self.nest_in_responses) #generate data message with data
#take care of includes
if response_obj.include_relationships != None: self.include_relationships = response_obj.include_relationships
included = None
janus_logger.info("Should map included: " + str(self.include_relationships))
if self.include_relationships:
included = self.__load_included(data,self.nest_in_responses)
#is there custome meta?
#first check if there is an response object
#if not nothing to return so HTTP 204
#otherwise process response
if response_obj == None:
if self.before_send_hook != None:
self.before_send_hook(204,None,None)
janus_logger.debug("Decorated function returned None. Nothing to map.")
return None
else:
#check response object
if isinstance(response_obj,JanusResponse) == False:
#janus_logger.error("Expected JanusResponse got " + str(type(response_obj)))
#raise Exception('Return value has to be instance of JanusResponse')
janus_logger.info("Not a JanusResponse. Will return this as it is. No mapping.")
return response_obj
message = None
#caching
loaded_from_cache = False
if self.cached_get_hook != None:
cached_object = self.cached_get_hook(response_obj)
if cached_object != None:
loaded_from_cache = True
message = cached_object #returned cached, already mapped, response
janus_logger.info("Will return cached message: " + str(loaded_from_cache))
if loaded_from_cache == False: #nothing in cache or cache deactivated