Mercurial > libervia-backend
comparison src/tools/xml_tools.py @ 655:56f8a9c99194
core, primitivus: better support for parameter of type list
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 02 Oct 2013 17:38:29 +0200 |
parents | 17bd09cd1001 |
children | 69a8bfd266a5 |
comparison
equal
deleted
inserted
replaced
654:5c5cf5bca240 | 655:56f8a9c99194 |
---|---|
146 if not name: | 146 if not name: |
147 error(_('INTERNAL ERROR: params must have a name')) | 147 error(_('INTERNAL ERROR: params must have a name')) |
148 assert(False) | 148 assert(False) |
149 type_ = param.getAttribute('type') | 149 type_ = param.getAttribute('type') |
150 value = param.getAttribute('value') or None | 150 value = param.getAttribute('value') or None |
151 options = getOptions(param) | |
151 callback_id = param.getAttribute('callback_id') or None | 152 callback_id = param.getAttribute('callback_id') or None |
152 if type_ == "button": | 153 if type_ == "button": |
153 param_ui.addEmpty() | 154 param_ui.addEmpty() |
154 else: | 155 else: |
155 param_ui.addLabel(label or name) | 156 param_ui.addLabel(label or name) |
156 param_ui.addElement(name=name, type_=type_, value=value, callback_id=callback_id) | 157 param_ui.addElement(name=name, type_=type_, value=value, options=options, callback_id=callback_id) |
157 | 158 |
158 return param_ui.toXml() | 159 return param_ui.toXml() |
160 | |
161 | |
162 def getOptions(param): | |
163 """Retrieve the options for list element. Allow listing the <option/> | |
164 tags directly in <param/> or in an intermediate <options/> tag.""" | |
165 elems = param.getElementsByTagName("options") | |
166 if len(elems) == 0: | |
167 elems = param.getElementsByTagName("option") | |
168 else: | |
169 elems = elems.item(0).getElementsByTagName("option") | |
170 if len(elems) == 0: | |
171 return [] | |
172 return [elem.getAttribute("value") for elem in elems] | |
159 | 173 |
160 | 174 |
161 class Header(object): | 175 class Header(object): |
162 """AdvandeList's header""" | 176 """AdvandeList's header""" |
163 | 177 |