Mercurial > libervia-backend
comparison libervia/backend/tools/common/template_xmlui.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 26b7ed2817da |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
24 | 24 |
25 from functools import partial | 25 from functools import partial |
26 from libervia.backend.core.log import getLogger | 26 from libervia.backend.core.log import getLogger |
27 from libervia.frontends.tools import xmlui | 27 from libervia.frontends.tools import xmlui |
28 from libervia.frontends.tools import jid | 28 from libervia.frontends.tools import jid |
29 | |
29 try: | 30 try: |
30 from jinja2 import Markup as safe | 31 from jinja2 import Markup as safe |
31 except ImportError: | 32 except ImportError: |
32 # Safe marks XHTML values as usable as it. | 33 # Safe marks XHTML values as usable as it. |
33 # If jinja2 is not there, we can use a simple lamba | 34 # If jinja2 is not there, we can use a simple lamba |
156 | 157 |
157 | 158 |
158 class JidInputWidget(xmlui.JidInputWidget, StringWidget): | 159 class JidInputWidget(xmlui.JidInputWidget, StringWidget): |
159 type = "jid" | 160 type = "jid" |
160 | 161 |
162 | |
161 class TextBoxWidget(xmlui.TextWidget, InputWidget): | 163 class TextBoxWidget(xmlui.TextWidget, InputWidget): |
162 type = "textbox" | 164 type = "textbox" |
163 | 165 |
164 | 166 |
165 class XHTMLBoxWidget(xmlui.XHTMLBoxWidget, InputWidget): | 167 class XHTMLBoxWidget(xmlui.XHTMLBoxWidget, InputWidget): |
168 def __init__(self, xmlui_parent, value, read_only=False): | 170 def __init__(self, xmlui_parent, value, read_only=False): |
169 # XXX: XHTMLBoxWidget value must be cleaned (harmful XHTML must be removed) | 171 # XXX: XHTMLBoxWidget value must be cleaned (harmful XHTML must be removed) |
170 # This is normally done in the backend, the frontends should not need to | 172 # This is normally done in the backend, the frontends should not need to |
171 # worry about it. | 173 # worry about it. |
172 super(XHTMLBoxWidget, self).__init__( | 174 super(XHTMLBoxWidget, self).__init__( |
173 xmlui_parent=xmlui_parent, value=safe(value), read_only=read_only) | 175 xmlui_parent=xmlui_parent, value=safe(value), read_only=read_only |
176 ) | |
174 | 177 |
175 | 178 |
176 class ListWidget(xmlui.ListWidget, OptionsWidget): | 179 class ListWidget(xmlui.ListWidget, OptionsWidget): |
177 type = "list" | 180 type = "list" |
178 | 181 |
236 | 239 |
237 def __init__(*args, **kwargs): | 240 def __init__(*args, **kwargs): |
238 raise NotImplementedError | 241 raise NotImplementedError |
239 | 242 |
240 | 243 |
241 create = partial(xmlui.create, class_map={ | 244 create = partial( |
242 xmlui.CLASS_PANEL: XMLUIPanel, | 245 xmlui.create, |
243 xmlui.CLASS_DIALOG: XMLUIDialog}) | 246 class_map={xmlui.CLASS_PANEL: XMLUIPanel, xmlui.CLASS_DIALOG: XMLUIDialog}, |
247 ) |