本文整理汇总了Python中website.util.sanitize.escape_html函数的典型用法代码示例。如果您正苦于以下问题:Python escape_html函数的具体用法?Python escape_html怎么用?Python escape_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了escape_html函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _send_with_data
def _send_with_data(self, url, method='post', output='json', **kwargs):
mapper = kwargs.get('mapper')
if mapper:
del kwargs['mapper']
files = kwargs.get('files')
data = kwargs.get('data')
func = getattr(self.session, method.lower())
req = None
headers = {}
if data:
headers = {'content-type': 'application/json'}
req = func(url, headers=headers, **kwargs)
elif files:
req = func(url, **kwargs)
if 200 <= req.status_code < 300:
if output is None:
return req
rv = getattr(req, output)
if mapper:
return mapper(escape_html(rv))
elif callable(rv):
return escape_html(rv())
return rv
else:
self.handle_error(req)
开发者ID:atelic,项目名称:osf.io,代码行数:29,代码来源:api.py
示例2: user_choose_mailing_lists
def user_choose_mailing_lists(auth, **kwargs):
""" Update mailing list subscription on user model and in mailchimp
Example input:
{
"Open Science Framework General": true,
...
}
"""
user = auth.user
json_data = escape_html(request.get_json())
if json_data:
for list_name, subscribe in json_data.items():
# TO DO: change this to take in any potential non-mailchimp, something like try: update_subscription(), except IndexNotFound: update_mailchimp_subscription()
if list_name == settings.OSF_HELP_LIST:
update_osf_help_mails_subscription(user=user, subscribe=subscribe)
else:
update_mailchimp_subscription(user, list_name, subscribe)
else:
raise HTTPError(
http.BAD_REQUEST,
data=dict(message_long="Must provide a dictionary of the format {'mailing list name': Boolean}"),
)
user.save()
all_mailing_lists = {}
all_mailing_lists.update(user.mailchimp_mailing_lists)
all_mailing_lists.update(user.osf_mailing_lists)
return {"message": "Successfully updated mailing lists", "result": all_mailing_lists}, 200
开发者ID:cwisecarver,项目名称:osf.io,代码行数:30,代码来源:views.py
示例3: update
def update(self, revision, data, user=None):
"""Figshare does not support versioning.
Always pass revision as None to avoid conflict.
"""
self.name = data['name']
self.materialized_path = data['materialized']
self.save()
version = FileVersion(identifier=None)
version.update_metadata(data, save=False)
# Draft files are not renderable
if data['extra']['status'] == 'drafts':
return (version, u'''
<style>
.file-download{{display: none;}}
.file-share{{display: none;}}
</style>
<div class="alert alert-info" role="alert">
The file "{name}" is still a draft on figshare. <br>
To view it on the OSF <a href="http://figshare.com/faqs">publish</a> it on figshare.
</div>
'''.format(name=escape_html(self.name)))
return version
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:25,代码来源:figshare.py
示例4: renderable_error
def renderable_error(self):
return u'''
<div class="alert alert-info" role="alert">
The file "{name}" is still a draft on figshare. <br>
To view it on the OSF <a href="http://figshare.com/faqs">publish</a> it on figshare.
</div>
'''.format(name=escape_html(self.file_guid.name))
开发者ID:GageGaskins,项目名称:osf.io,代码行数:7,代码来源:exceptions.py
示例5: unserialize_names
def unserialize_names(**kwargs):
user = kwargs["auth"].user
json_data = escape_html(request.get_json())
# json get can return None, use `or` here to ensure we always strip a string
user.fullname = (json_data.get("full") or "").strip()
user.given_name = (json_data.get("given") or "").strip()
user.middle_names = (json_data.get("middle") or "").strip()
user.family_name = (json_data.get("family") or "").strip()
user.suffix = (json_data.get("suffix") or "").strip()
user.save()
开发者ID:cwisecarver,项目名称:osf.io,代码行数:10,代码来源:views.py
示例6: unserialize_names
def unserialize_names(**kwargs):
user = kwargs['auth'].user
json_data = escape_html(request.get_json())
# json get can return None, use `or` here to ensure we always strip a string
user.fullname = (json_data.get('full') or '').strip()
user.given_name = (json_data.get('given') or '').strip()
user.middle_names = (json_data.get('middle') or '').strip()
user.family_name = (json_data.get('family') or '').strip()
user.suffix = (json_data.get('suffix') or '').strip()
user.save()
开发者ID:DanielSBrown,项目名称:osf.io,代码行数:10,代码来源:views.py
示例7: unserialize_contents
def unserialize_contents(field, func, auth):
user = auth.user
json_data = escape_html(request.get_json())
setattr(
user,
field,
[
func(content)
for content in json_data.get('contents', [])
]
)
user.save()
开发者ID:DanielSBrown,项目名称:osf.io,代码行数:12,代码来源:views.py
示例8: unserialize_social
def unserialize_social(auth, **kwargs):
verify_user_match(auth, **kwargs)
user = auth.user
json_data = escape_html(request.get_json())
for soc in user.SOCIAL_FIELDS.keys():
user.social[soc] = json_data.get(soc)
try:
user.save()
except ValidationError as exc:
raise HTTPError(http.BAD_REQUEST, data=dict(message_long=exc.args[0]))
开发者ID:cwisecarver,项目名称:osf.io,代码行数:14,代码来源:views.py
示例9: create_badge
def create_badge(*args, **kwargs):
badge_data = request.json
awarder = kwargs['user_addon']
if (not badge_data or not badge_data.get('badgeName') or
not badge_data.get('description') or
not badge_data.get('imageurl') or
not badge_data.get('criteria')):
raise HTTPError(http.BAD_REQUEST)
try:
id = Badge.create(awarder, escape_html(badge_data))._id
return {'badgeid': id}, http.CREATED
except IOError:
raise HTTPError(http.BAD_REQUEST)
开发者ID:545zhou,项目名称:osf.io,代码行数:15,代码来源:crud.py
示例10: _send
def _send(self, url, method='get', output='json', cache=True, **kwargs):
func = getattr(self.session, method.lower())
# Send request
req = func(url, **kwargs)
# Get return value
rv = None
if 200 <= req.status_code < 300:
if output is None:
rv = req
else:
rv = getattr(req, output)
if callable(rv):
rv = rv()
return escape_html(rv)
else:
self.last_error = req.status_code
return False
开发者ID:atelic,项目名称:osf.io,代码行数:19,代码来源:api.py
示例11: user_choose_mailing_lists
def user_choose_mailing_lists(auth, **kwargs):
""" Update mailing list subscription on user model and in mailchimp
Example input:
{
"Open Science Framework General": true,
...
}
"""
user = auth.user
json_data = escape_html(request.get_json())
if json_data:
for list_name, subscribe in json_data.items():
update_subscription(user, list_name, subscribe)
else:
raise HTTPError(http.BAD_REQUEST, data=dict(
message_long="Must provide a dictionary of the format {'mailing list name': Boolean}")
)
user.save()
return {'message': 'Successfully updated mailing lists', 'result': user.mailing_lists}, 200
开发者ID:GageGaskins,项目名称:osf.io,代码行数:22,代码来源:views.py
示例12: meeting_hook
def meeting_hook():
# Fail if not from Mailgun
check_mailgun_headers()
form = escape_html(request.form.to_dict())
meeting, category = parse_mailgun_receiver(form)
conf = Conference.find(Q('endpoint', 'iexact', meeting))
if conf.count():
conf = conf[0]
else:
raise HTTPError(http.NOT_FOUND)
# Fail if not found or inactive
# Note: Throw 406 to disable Mailgun retries
try:
if not conf.active:
logger.error('Conference {0} is not active'.format(conf.endpoint))
raise HTTPError(http.NOT_ACCEPTABLE)
except KeyError:
# TODO: Can this ever be reached?
raise HTTPError(http.NOT_ACCEPTABLE)
name, address = get_mailgun_from()
# Add poster
add_poster_by_email(
conf=conf,
recipient=form['recipient'],
address=address,
fullname=name,
subject=get_mailgun_subject(form),
message=form['stripped-text'],
attachments=get_mailgun_attachments(),
tags=[meeting],
system_tags=[meeting],
is_spam=check_mailgun_spam(),
)
开发者ID:RafaelWillian,项目名称:osf.io,代码行数:39,代码来源:views.py
示例13: user_choose_addons
def user_choose_addons(**kwargs):
auth = kwargs["auth"]
json_data = escape_html(request.get_json())
auth.user.config_addons(json_data, auth)
开发者ID:cwisecarver,项目名称:osf.io,代码行数:4,代码来源:views.py
注:本文中的website.util.sanitize.escape_html函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论