本文整理汇总了Python中gluon.html.xmlescape方法的典型用法代码示例。如果您正苦于以下问题:Python html.xmlescape方法的具体用法?Python html.xmlescape怎么用?Python html.xmlescape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.html
的用法示例。
在下文中一共展示了html.xmlescape方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def download(current, upload_id, filename=None):
db = current.db
response = current.response
if filename is None:
filename = "download_" + upload_id
row = db(db.uploads.id == upload_id).select().first()
if row:
response.headers[blobstore.BLOB_KEY_HEADER] = row.blob_key
response.headers["Content-Type"] = "application/octet-stream"
response.headers["Content-Disposition"] = (
'attachment; filename="%s"' % html.xmlescape(filename))
audit.log(current, "FileDownload", upload_id=upload_id)
else:
raise ValueError("not found")
示例2: write
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def write(self, data, escape=True):
if not escape:
self.body.write(str(data))
else:
self.body.write(to_native(xmlescape(data)))
示例3: include_meta
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def include_meta(self):
s = "\n"
for meta in iteritems((self.meta or {})):
k, v = meta
if isinstance(v, dict):
s += '<meta' + ''.join(' %s="%s"' % (xmlescape(key),
to_native(xmlescape(v[key]))) for key in v) + ' />\n'
else:
s += '<meta name="%s" content="%s" />\n' % (k, to_native(xmlescape(v)))
self.write(s, escape=False)
示例4: xml_rec
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def xml_rec(value, key, quote=True):
if hasattr(value, 'custom_xml') and callable(value.custom_xml):
return value.custom_xml()
elif isinstance(value, (dict, Storage)):
return TAG[key](*[TAG[k](xml_rec(v, '', quote))
for k, v in value.items()])
elif isinstance(value, list):
return TAG[key](*[TAG.item(xml_rec(item, '', quote)) for item in value])
elif hasattr(value, 'as_list') and callable(value.as_list):
return str(xml_rec(value.as_list(), '', quote))
elif hasattr(value, 'as_dict') and callable(value.as_dict):
return str(xml_rec(value.as_dict(), '', quote))
else:
return xmlescape(value, quote)
示例5: apply_filter
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def apply_filter(self, message, symbols={}, filter=None, ftag=None):
def get_tr(message, prefix, filter):
s = self.get_t(message, prefix)
return filter(s) if filter else self.filter(s)
if filter:
prefix = '@' + (ftag or 'userdef') + '\x01'
else:
prefix = '@' + self.ftag + '\x01'
message = get_from_cache(
self.cache, prefix + message,
lambda: get_tr(message, prefix, filter))
if symbols or symbols == 0 or symbols == "":
if isinstance(symbols, dict):
symbols.update(
(key, xmlescape(value).translate(ttab_in))
for key, value in iteritems(symbols)
if not isinstance(value, NUMBERS))
else:
if not isinstance(symbols, tuple):
symbols = (symbols,)
symbols = tuple(
value if isinstance(value, NUMBERS)
else to_native(xmlescape(value)).translate(ttab_in)
for value in symbols)
message = self.params_substitution(message, symbols)
return to_native(XML(message.translate(ttab_out)).xml())
示例6: write
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def write(self, data, escape=True):
if not escape:
self.body.write(str(data))
else:
self.body.write(xmlescape(data))
示例7: include_meta
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def include_meta(self):
s = "\n"
for meta in (self.meta or {}).iteritems():
k, v = meta
if isinstance(v, dict):
s += '<meta' + ''.join(' %s="%s"' % (xmlescape(key), xmlescape(v[key])) for key in v) +' />\n'
else:
s += '<meta name="%s" content="%s" />\n' % (k, xmlescape(v))
self.write(s, escape=False)
示例8: apply_filter
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def apply_filter(self, message, symbols={}, filter=None, ftag=None):
def get_tr(message, prefix, filter):
s = self.get_t(message, prefix)
return filter(s) if filter else self.filter(s)
if filter:
prefix = '@' + (ftag or 'userdef') + '\x01'
else:
prefix = '@' + self.ftag + '\x01'
message = get_from_cache(
self.cache, prefix + message,
lambda: get_tr(message, prefix, filter))
if symbols or symbols == 0 or symbols == "":
if isinstance(symbols, dict):
symbols.update(
(key, xmlescape(value).translate(ttab_in))
for key, value in symbols.iteritems()
if not isinstance(value, NUMBERS))
else:
if not isinstance(symbols, tuple):
symbols = (symbols,)
symbols = tuple(
value if isinstance(value, NUMBERS)
else xmlescape(value).translate(ttab_in)
for value in symbols)
message = self.params_substitution(message, symbols)
return XML(message.translate(ttab_out))
示例9: write
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def write(self, data, escape=True):
if not escape:
self.body.write(str(data))
else:
# FIXME PY3:
self.body.write(to_native(xmlescape(data)))
示例10: include_meta
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def include_meta(self):
s = "\n"
for meta in iteritems((self.meta or {})):
k, v = meta
if isinstance(v, dict):
s += '<meta' + ''.join(' %s="%s"' % (xmlescape(key), to_native(xmlescape(v[key]))) for key in v) +' />\n'
else:
s += '<meta name="%s" content="%s" />\n' % (k, to_native(xmlescape(v)))
self.write(s, escape=False)
示例11: include_meta
# 需要导入模块: from gluon import html [as 别名]
# 或者: from gluon.html import xmlescape [as 别名]
def include_meta(self):
s = "\n";
for meta in (self.meta or {}).iteritems():
k,v = meta
if isinstance(v,dict):
s = s+'<meta'+''.join(' %s="%s"' % (xmlescape(key), xmlescape(v[key])) for key in v) +' />\n'
else:
s = s+'<meta name="%s" content="%s" />\n' % (k, xmlescape(v))
self.write(s, escape=False)