示例#1
0
 def render(self, request):
     if self.widget_type == "multiple_select":
         multiple = "multiple"
     else:
         multiple = None
     if self.widget_type == "option_select":
         onchange = "submit()"
     else:
         onchange = None
     tags = [
         htmltag(
             "select",
             name=self.name,
             multiple=multiple,
             onchange=onchange,
             size=self.size,
         )
     ]
     for object, description, key in self.options:
         if self.is_selected(object):
             selected = "selected"
         else:
             selected = None
         if description is None:
             description = ""
         r = htmltag("option", value=key, selected=selected)
         tags.append(r + htmlescape(description) + htmltext('</option>'))
     tags.append(htmltext("</select>"))
     return htmltext("\n").join(tags)
示例#2
0
文件: widget.py 项目: pganti/micheles
 def render_content(self):
     tags = [htmltag("select", name=self.name, **self.attrs)]
     for object, description, key in self.options:
         if self.is_selected(object):
             selected = 'selected'
         else:
             selected = None
         if description is None:
             description = ""
         r = htmltag("option", value=key, selected=selected)
         tags.append(r + htmlescape(description) + htmltext('</option>'))
     tags.append(htmltext("</select>"))
     return htmltext("\n").join(tags)
示例#3
0
 def render_content(self):
     tags = [htmltag("select", name=self.name, **self.attrs)]
     for object, description, key in self.options:
         if self.is_selected(object):
             selected = 'selected'
         else:
             selected = None
         if description is None:
             description = ""
         r = htmltag("option", value=key, selected=selected)
         tags.append(r + htmlescape(description) + htmltext('</option>'))
     tags.append(htmltext("</select>"))
     return htmltext("\n").join(tags)
示例#4
0
文件: widget.py 项目: pganti/micheles
 def render(self, request):
     return htmltag("input",
                    xml_end=1,
                    type="checkbox",
                    name=self.name,
                    value="yes",
                    checked=self.value and "checked" or None)
示例#5
0
文件: widget.py 项目: pganti/micheles
 def render_content(self):
     return htmltag("input",
                    xml_end=True,
                    type=self.HTML_TYPE,
                    name=self.name,
                    value=self.value,
                    **self.attrs)
示例#6
0
文件: form.py 项目: pganti/micheles
 def _render_start(self):
     r = TemplateIO(html=True)
     r += htmltag('form', method=self.method,
                  enctype=self.enctype, action=self.action,
                  **self.attrs)
     r += self._render_hidden_widgets()
     return r.getvalue()
示例#7
0
 def render_content(self):
     return htmltag("input", xml_end=True,
                    type="checkbox",
                    name=self.name,
                    value="yes",
                    checked=self.value and "checked" or None,
                    **self.attrs)
示例#8
0
文件: widget.py 项目: pganti/micheles
 def render(self, request):
     value = (self.value and htmlescape(self.value) or None)
     return htmltag("input",
                    xml_end=1,
                    type="submit",
                    name=self.name,
                    value=value)
示例#9
0
 def _render_start(self, request, action,
                   enctype=None, method='post', name=None):
     r = TemplateIO(html=1)
     r += htmltag('form', enctype=enctype, method=method,
                  action=action, name=name)
     r += self._render_hidden_widgets(request)
     return r.getvalue()
示例#10
0
 def _render_start(self):
     r = TemplateIO(html=True)
     r += htmltag('form', name=self.name, method=self.method,
                  enctype=self.enctype, action=self.action_url,
                  **self.attrs)
     r += self._render_hidden_widgets()
     return r.getvalue()
示例#11
0
 def render(self, request, **attributes):
     return htmltag("input", xml_end=1,
                    type=self.html_type,
                    name=self.name,
                    size=self.size,
                    maxlength=self.maxlength,
                    value=self.value,
                    **attributes)
示例#12
0
文件: widget.py 项目: pganti/micheles
 def render_content(self):
     return htmltag("input",
                    xml_end=True,
                    type="checkbox",
                    name=self.name,
                    value="yes",
                    checked=self.value and "checked" or None,
                    **self.attrs)
示例#13
0
 def render(self, request):
     return (htmltag("textarea", name=self.name,
                     cols=self.cols,
                     rows=self.rows,
                     wrap=self.wrap,
                     css_class=self.css_class) +
             htmlescape(self.value or "") +
             htmltext("</textarea>"))
示例#14
0
文件: widget.py 项目: zhou0/quixote
 def render(self, request):
     return (htmltag("textarea", name=self.name,
                     cols=self.cols,
                     rows=self.rows,
                     wrap=self.wrap,
                     css_class=self.css_class) +
             htmlescape(self.value or "") +
             htmltext("</textarea>"))
示例#15
0
 def render_content(self):
     # slightly different behavior here, we always render the
     # tag using the 'value' passed in as a parameter.  'self.value'
     # is a boolean that is true if the button's name appears
     # in the request.
     value = (self.label and htmlescape(self.label) or None)
     return htmltag("input", xml_end=True, type=self.HTML_TYPE,
                    name=self.name, value=value, **self.attrs)
示例#16
0
 def render(self, request):
     if self.value is None:
         value = None
     else:
         value = htmlescape(self.value)
     return htmltag(
         "input", xml_end=1, type="hidden", name=self.name, value=value
     )
示例#17
0
文件: widget.py 项目: zhou0/quixote
 def render(self, request, **attributes):
     return htmltag("input", xml_end=1,
                    type=self.html_type,
                    name=self.name,
                    size=self.size,
                    maxlength=self.maxlength,
                    value=self.value,
                    **attributes)
示例#18
0
 def render(self, request):
     if self.value is None:
         value = None
     else:
         value = htmlescape(self.value)
     return htmltag("input", xml_end=1,
                    type="hidden",
                    name=self.name,
                    value=value)
示例#19
0
 def render_content(self):
     if self.value is None:
         value = None
     else:
         value = htmlescape(self.value)
     return htmltag("input", xml_end=True,
                    type="hidden",
                    name=self.name,
                    value=value,
                    **self.attrs)
示例#20
0
文件: widget.py 项目: pganti/micheles
 def render_content(self):
     if self.value is None:
         value = None
     else:
         value = htmlescape(self.value)
     return htmltag("input",
                    xml_end=True,
                    type="hidden",
                    name=self.name,
                    value=value,
                    **self.attrs)
示例#21
0
文件: widget.py 项目: pganti/micheles
 def render_content(self):
     # slightly different behavior here, we always render the
     # tag using the 'value' passed in as a parameter.  'self.value'
     # is a boolean that is true if the button's name appears
     # in the request.
     value = (self.label and htmlescape(self.label) or None)
     return htmltag("input",
                    xml_end=True,
                    type=self.HTML_TYPE,
                    name=self.name,
                    value=value,
                    **self.attrs)
示例#22
0
 def render(self, request):
     tags = []
     for object, description, key in self.options:
         if self.is_selected(object):
             checked = ValuelessAttr
         else:
             checked = None
         r = htmltag("input", xml_end=True,
                     type="radio",
                     name=self.name,
                     value=key,
                     checked=checked)
         tags.append(r + htmlescape(description))
     return htmlescape(self.delim).join(tags)
示例#23
0
 def render(self, request):
     if self.widget_type == "multiple_select":
         multiple = ValuelessAttr
     else:
         multiple = None
     if self.widget_type == "option_select":
         onchange = "submit()"
     else:
         onchange = None
     tags = [htmltag("select", name=self.name,
                     multiple=multiple, onchange=onchange,
                     size=self.size)]
     for object, description, key in self.options:
         if self.is_selected(object):
             selected = ValuelessAttr
         else:
             selected = None
         if description is None:
             description = ""
         r = htmltag("option", value=key, selected=selected)
         tags.append(r + htmlescape(description) + htmltext('</option>'))
     tags.append(htmltext("</select>"))
     return htmltext("\n").join(tags)
示例#24
0
文件: widget.py 项目: zhou0/quixote
 def render(self, request):
     tags = []
     for object, description, key in self.options:
         if self.is_selected(object):
             checked = "checked"
         else:
             checked = None
         r = htmltag("input", xml_end=True,
                     type="radio",
                     name=self.name,
                     value=key,
                     checked=checked)
         tags.append(r + htmlescape(description))
     return htmlescape(self.delim).join(tags)
示例#25
0
 def render_content(self):
     tags = []
     for object, description, key in self.options:
         if self.is_selected(object):
             checked = 'checked'
         else:
             checked = None
         r = htmltag("input", xml_end=True,
                     type="radio",
                     name=self.name,
                     value=key,
                     checked=checked,
                     **self.attrs)
         tags.append(r + htmlescape(description))
     return htmlescape(self.delim).join(tags)
示例#26
0
 def render_content(self):
     tags = []
     for object, description, key in self.options:
         if self.is_selected(object):
             checked = 'checked'
         else:
             checked = None
         r = htmltag(
             "input",
             xml_end=True,
             type="radio",
             name=self.name,
             value=key,
             checked=checked,
             **self.attrs,
         )
         tags.append(r + htmlescape(description))
     return htmlescape(self.delim).join(tags)
示例#27
0
 def render_content(self):
     return htmltag("input", xml_end=True,
                    type=self.HTML_TYPE,
                    name=self.name,
                    value=self.value,
                    **self.attrs)
示例#28
0
 def render_content(self):
     return (htmltag("textarea", name=self.name, **self.attrs) +
             htmlescape(self.value or "") +
             htmltext("</textarea>"))
示例#29
0
 def render(self, request):
     value = (self.value and htmlescape(self.value) or None)
     return htmltag("input", xml_end=1, type="submit",
                    name=self.name, value=value)
示例#30
0
 def render(self, request):
     return htmltag("input", xml_end=1,
                    type="checkbox",
                    name=self.name,
                    value="yes",
                    checked=self.value and ValuelessAttr or None)
示例#31
0
文件: widget.py 项目: pganti/micheles
 def render_content(self):
     return (htmltag("textarea", name=self.name, **self.attrs) +
             htmlescape(self.value or "") + htmltext("</textarea>"))