Example #1
0
    def __init__(self, xml_raw, mode='train'):
        """
        Constructor responsible to set class attributes and
        to process the right request

        :param: xml_raw
        :param: mode
        :return: None
        """

        # Gets all config from the DB
        config_options = Config.objects.all()
        config = {}
        for config_option in config_options:
            config[config_option.id] = config_option.value

        # Instantiates class attributes
        self.mode = mode
        self.config_info = config
        self.request_xml = XmlManager(xml_raw)
        self.response_xml = XmlManager()
        self.ron = Ron(config, mode)
        self.viator = Viator(self.request_xml, self.response_xml)

        # Errors
        self.errors = {
            'VRONERR001': 'Malformed or missing elements',
            'VRONERR002': 'Invalid API KEY',
            'VRONERR003': 'RON authentication failed',
            'VRONERR004': 'Nothing returned',
        }