def get_messages(self, character, max_messages, popup=None, unread=False): query = Message.all().filter('recipient', character) if popup: query.filter('pop_message_box', True) #only get messages that need to be shown in popup message box if unread: query.filter('read_by_user', False) message_list = query.fetch(max_messages) return message_list