comparison sat/tools/common/template_xmlui.py @ 3271:abca25af06d7

plugin pubsub schema, tools (common/template xmlui): use a JID for publisher: - a JidWidget is used instead of text for publisher, nothing is set if publisher attribute doesn't exist - added missing JidWidget implementation in tools.common.template_xmlui
author Goffi <goffi@goffi.org>
date Mon, 18 May 2020 23:37:04 +0200
parents 559a625a236b
children be6d91572633
comparison
equal deleted inserted replaced
3270:0c3b7ee2628f 3271:abca25af06d7
20 """ template XMLUI parsing 20 """ template XMLUI parsing
21 21
22 XMLUI classes from this modules can then be iterated to create the template 22 XMLUI classes from this modules can then be iterated to create the template
23 """ 23 """
24 24
25 from functools import partial
25 from sat.core.log import getLogger 26 from sat.core.log import getLogger
26
27 log = getLogger(__name__)
28 from sat_frontends.tools import xmlui 27 from sat_frontends.tools import xmlui
29 from functools import partial 28 from sat_frontends.tools import jid
30 try: 29 try:
31 from jinja2 import Markup as safe 30 from jinja2 import Markup as safe
32 except ImportError: 31 except ImportError:
33 # Safe marks XHTML values as usable as it. 32 # Safe marks XHTML values as usable as it.
34 # If jinja2 is not there, we can use a simple lamba 33 # If jinja2 is not there, we can use a simple lamba
35 safe = lambda x: x 34 safe = lambda x: x
36 35
37 36
37 log = getLogger(__name__)
38
39
38 ## Widgets ## 40 ## Widgets ##
39 41
40 42
41 class Widget(object): 43 class Widget(object):
42 category = "widget" 44 category = "widget"
117 119
118 class TextWidget(xmlui.TextWidget, ValueWidget): 120 class TextWidget(xmlui.TextWidget, ValueWidget):
119 type = "text" 121 type = "text"
120 122
121 123
124 class JidWidget(xmlui.JidWidget, ValueWidget):
125 type = "jid"
126
127 def __init__(self, xmlui_parent, value):
128 self.value = jid.JID(value)
129
130
122 class LabelWidget(xmlui.LabelWidget, ValueWidget): 131 class LabelWidget(xmlui.LabelWidget, ValueWidget):
123 type = "label" 132 type = "label"
124 133
125 @property 134 @property
126 def for_name(self): 135 def for_name(self):
134 type = "string" 143 type = "string"
135 144
136 145
137 class JidInputWidget(xmlui.JidInputWidget, StringWidget): 146 class JidInputWidget(xmlui.JidInputWidget, StringWidget):
138 type = "jid" 147 type = "jid"
139
140 148
141 class TextBoxWidget(xmlui.TextWidget, InputWidget): 149 class TextBoxWidget(xmlui.TextWidget, InputWidget):
142 type = "textbox" 150 type = "textbox"
143 151
144 152