我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用net.websafe()。
def render(self): attrs = self.attrs.copy() attrs['name'] = self.name x = '<select %s>\n' % attrs for arg in self.args: if isinstance(arg, (tuple, list)): value, desc= arg else: value, desc = arg, arg if self.value == value or (isinstance(self.value, list) and value in self.value): select_p = ' selected="selected"' else: select_p = '' x += ' <option%s value="%s">%s</option>\n' % (select_p, net.websafe(value), net.websafe(desc)) x += '</select>\n' return x
def render(self): x = '<span>' for arg in self.args: if isinstance(arg, (tuple, list)): value, desc= arg else: value, desc = arg, arg attrs = self.attrs.copy() attrs['name'] = self.name attrs['type'] = 'radio' attrs['value'] = value if self.value == value: attrs['checked'] = 'checked' x += '<input %s/> %s' % (attrs, net.websafe(desc)) x += '</span>' return x
def profiler(app): """Outputs basic profiling information at the bottom of each response.""" from utils import profile def profile_internal(e, o): out, result = profile(app)(e, o) return list(out) + ['<pre>' + net.websafe(result) + '</pre>'] return profile_internal
def render(self): out = '' out += self.rendernote(self.note) out += '<table>\n' for i in self.inputs: html = utils.safeunicode(i.pre) + i.render() + self.rendernote(i.note) + utils.safeunicode(i.post) if i.is_hidden(): out += ' <tr style="display: none;"><th></th><td>%s</td></tr>\n' % (html) else: out += ' <tr><th><label for="%s">%s</label></th><td>%s</td></tr>\n' % (i.id, net.websafe(i.description), html) out += "</table>" return out
def render_css(self): out = [] out.append(self.rendernote(self.note)) for i in self.inputs: if not i.is_hidden(): out.append('<label for="%s">%s</label>' % (i.id, net.websafe(i.description))) out.append(i.pre) out.append(i.render()) out.append(self.rendernote(i.note)) out.append(i.post) out.append('\n') return ''.join(out)
def rendernote(self, note): if note: return '<strong class="wrong">%s</strong>' % net.websafe(note) else: return ""
def render(self): attrs = self.attrs.copy() attrs['name'] = self.name value = net.websafe(self.value or '') return '<textarea %s>%s</textarea>' % (attrs, value)
def render(self): attrs = self.attrs.copy() attrs['name'] = self.name if self.value is not None: attrs['value'] = self.value html = attrs.pop('html', None) or net.websafe(self.name) return '<button %s>%s</button>' % (attrs, html)
def _render_option(self, arg, indent=' '): if isinstance(arg, (tuple, list)): value, desc= arg else: value, desc = arg, arg if self.value == value or (isinstance(self.value, list) and value in self.value): select_p = ' selected="selected"' else: select_p = '' return indent + '<option%s value="%s">%s</option>\n' % (select_p, net.websafe(value), net.websafe(desc))
def render(self): attrs = self.attrs.copy() attrs['name'] = self.name x = '<select %s>\n' % attrs for label, options in self.args: x += ' <optgroup label="%s">\n' % net.websafe(label) for arg in options: x += self._render_option(arg, indent = ' ') x += ' </optgroup>\n' x += '</select>\n' return x
def __str__(self): return " ".join(['%s="%s"' % (k, net.websafe(v)) for k, v in self.items()])
def profiler(app): """Outputs basic profiling information at the bottom of each response.""" from utils import profile def profile_internal(e, o): out, result = profile(app)(e, o) return out + ['<pre>' + net.websafe(result) + '</pre>'] return profile_internal
def addatts(self): str = "" for (n, v) in self.attrs.items(): str += ' %s="%s"' % (n, net.websafe(v)) return str #@@ quoting
def render(self): x = '<input type="text" name="%s"' % net.websafe(self.name) if self.value: x += ' value="%s"' % net.websafe(self.value) x += self.addatts() x += ' />' return x
def render(self): x = '<input type="password" name="%s"' % net.websafe(self.name) if self.value: x += ' value="%s"' % net.websafe(self.value) x += self.addatts() x += ' />' return x
def render(self): x = '<textarea name="%s"' % net.websafe(self.name) x += self.addatts() x += '>' if self.value is not None: x += net.websafe(self.value) x += '</textarea>' return x
def render(self): x = '<span>' for arg in self.args: if self.value == arg: select_p = ' checked="checked"' else: select_p = '' x += '<input type="radio" name="%s" value="%s"%s%s /> %s ' % (net.websafe(self.name), net.websafe(arg), select_p, self.addatts(), net.websafe(arg)) return x+'</span>'
def render(self): x = '<input name="%s" type="checkbox"' % net.websafe(self.name) if self.value: x += ' checked="checked"' x += self.addatts() x += ' />' return x
def render(self): safename = net.websafe(self.name) x = '<button name="%s"%s>%s</button>' % (safename, self.addatts(), safename) return x
def render(self): x = '<input type="hidden" name="%s"' % net.websafe(self.name) if self.value: x += ' value="%s"' % net.websafe(self.value) x += ' />' return x
def render(self): x = '<input type="file" name="%s"' % net.websafe(self.name) x += self.addatts() x += ' />' return x