def __init__(self, xml_tag):
        self.xml_tag = xml_tag
        self.selected = []
        CheckboxesModule.__init__(self, options={}, label='', name='')

        # This modules automatically manages occurences
        self.is_managing_occurences = True
    def __init__(self, xml_tag):
        self.xml_tag = xml_tag
        self.selected = []
        CheckboxesModule.__init__(self, options={}, label='', name='')

        # This modules automatically manages occurences
        self.is_managing_occurences = True
    def __init__(self):
        self.options = {
            "Ac": "Actinium",
            "Al": "Aluminum",
            "Ag": "Silver",
            "Am": "Americium",
            "Ar": "Argon",
            "As": "Arsenic",
            "At": "Astatine",
            "Au": "Gold",
        }

        CheckboxesModule.__init__(self, options=self.options, label="Select elements", name="chemical")
    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)
Esempio n. 5
0
    def __init__(self):
        self.options = {
            'Ac': 'Actinium',
            'Al': 'Aluminum',
            'Ag': 'Silver',
            'Am': 'Americium',
            'Ar': 'Argon',
            'As': 'Arsenic',
            'At': 'Astatine',
            'Au': 'Gold'
        }

        CheckboxesModule.__init__(self,
                                  options=self.options,
                                  label='Select elements',
                                  name='chemical')
    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)
Esempio n. 7
0
 def _get_module(self, request):
     return CheckboxesModule.get_module(self, request)
 def _get_module(self, request):
     return CheckboxesModule.get_module(self, request)