def get_messages_for_api_calls(request):
 message_lists = []
 for message in get_messages(request):
  msg_txt = message.message
  if (not (isinstance(msg_txt, SafeString) or isinstance(msg_txt, SafeUnicode))):
   msg_txt = cgi.escape(unicode(msg_txt))
  msg_type = message.tags
  message_lists.append({msg_type: msg_txt})
 return message_lists

def get_messages_for_api_calls ( request ) : message_lists = [ ] for message in get_messages ( request ) : msg_txt = message . message if ( not ( isinstance ( msg_txt , SafeString ) or isinstance ( msg_txt , SafeUnicode ) ) ) : msg_txt = cgi . escape ( unicode ( msg_txt ) ) msg_type = message . tags message_lists . append ( { msg_type : msg_txt } ) return message_lists
re-usable function that returns a list of messages to be used by api calls .