def _get_module(self, request): self.selected = [] # get the values of the enumeration xml_doc_tree_str = request.session['xmlDocTree'] xml_doc_tree = etree.fromstring(xml_doc_tree_str) namespaces = common.get_namespaces(BytesIO(str(xml_doc_tree_str))) # get the element where the module is attached xsd_element = xml_doc_tree.xpath(request.GET['xsd_xpath'], namespaces=namespaces)[0] xsd_element_type = xsd_element.attrib['type'] # remove ns prefix if present if ':' in xsd_element_type: xsd_element_type = xsd_element_type.split(':')[1] xpath_type = "./{0}simpleType[@name='{1}']".format(LXML_SCHEMA_NAMESPACE, xsd_element_type) elementType = xml_doc_tree.find(xpath_type) enumeration_list = elementType.findall('./{0}restriction/{0}enumeration'.format(LXML_SCHEMA_NAMESPACE)) for enumeration in enumeration_list: self.options[enumeration.attrib['value']] = enumeration.attrib['value'] if 'data' in request.GET: data = request.GET['data'] # get XML to reload reload_data = etree.fromstring("<root>" + data + "</root>") for child in reload_data: self.selected.append(child.text.strip()) return CheckboxesModule.get_module(self, request)
def _get_module(self, request): self.selected = [] # get the values of the enumeration xml_doc_tree_str = request.session['xmlDocTree'] xml_doc_tree = etree.fromstring(xml_doc_tree_str) namespaces = common.get_namespaces(BytesIO(str(xml_doc_tree_str))) # get the element where the module is attached xsd_element = xml_doc_tree.xpath(request.GET['xsd_xpath'], namespaces=namespaces)[0] xsd_element_type = xsd_element.attrib['type'] # remove ns prefix if present if ':' in xsd_element_type: xsd_element_type = xsd_element_type.split(':')[1] xpath_type = "./{0}simpleType[@name='{1}']".format( LXML_SCHEMA_NAMESPACE, xsd_element_type) elementType = xml_doc_tree.find(xpath_type) enumeration_list = elementType.findall( './{0}restriction/{0}enumeration'.format(LXML_SCHEMA_NAMESPACE)) for enumeration in enumeration_list: self.options[ enumeration.attrib['value']] = enumeration.attrib['value'] if 'data' in request.GET: data = request.GET['data'] # get XML to reload reload_data = etree.fromstring("<root>" + data + "</root>") for child in reload_data: self.selected.append(child.text.strip()) return CheckboxesModule.get_module(self, request)
def _get_module(self, request): return CheckboxesModule.get_module(self, request)