本文整理汇总了Python中tornado.escape.xhtml_escape函数的典型用法代码示例。如果您正苦于以下问题:Python xhtml_escape函数的具体用法?Python xhtml_escape怎么用?Python xhtml_escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xhtml_escape函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post
def post(self):
initial = "(.*%s.*)" % (self.get_argument('search_string'))
for match in SEARCH.find({"search": { '$regex': initial}}):
response = """
<li class="list-group-item"><a onClick="a_onClick(\'%s\')">%s</a></li>
""" % (esc.xhtml_escape(match["search"]), esc.xhtml_escape(match["search"]))
self.write(response)
开发者ID:byouloh,项目名称:Hurricane,代码行数:7,代码来源:app.py
示例2: test_get_ag_details
def test_get_ag_details(self):
self.mock_login_admin()
# test if AGP data are rendered correctly
barcode = '000029153'
response = self.get('/barcode_util/', {'barcode': barcode})
self.assertEqual(response.code, 200)
self.assertIn('<h2>%s Details</h2>' % 'American Gut', response.body)
ag_details = db.getAGBarcodeDetails(barcode)
self.assertIn('<tr><td>Sample Date</td><td>%s</td></tr>'
% ag_details['sample_date'], response.body)
self.assertIn('<tr><td>Sample Time</td><td>%s</td></tr>'
% ag_details['sample_time'], response.body)
self.assertIn('<tr><td>Sample Site</td><td>%s</td></tr>'
% ag_details['site_sampled'], response.body)
self.assertIn('<label for="moldy"> moldy (current: %s) </label> <br />'
% ag_details['moldy'], response.body)
self.assertIn(('<label for="overloaded"> overloaded (current: %s) '
'</label> <br />') % ag_details['overloaded'],
response.body)
self.assertIn(('<label for="other"> other (current: %s) '
'</label> <br />') % ag_details['other'], response.body)
self.assertIn(('<textarea name="other_text" onclick="this.select()'
'">%s</textarea>') %
xhtml_escape(ag_details['other_text']),
response.body)
self.assertIn(('<label for="send_mail" style="display:block;">send kit'
' owner %s (%s) an email </label>')
% (xhtml_escape(ag_details['name']),
xhtml_escape(ag_details['email'])),
response.body)
开发者ID:josenavas,项目名称:labadmin,代码行数:33,代码来源:test_barcode_util.py
示例3: post_argv
def post_argv(self, post= None):
if post: # title
if 'title_seo' in post['post']:
title_seo = escape.xhtml_escape(post['post']['title_seo'])
else:
title_seo = ''
if 'title' in post['post']:
title = escape.xhtml_escape("%s (%s)" % (post['post']['title'], post['post']['year']))
else:
title = ""
# poster
if 'poster' in post['post']:
poster = escape.xhtml_escape(post['post']['poster'])
else:
poster = ""
###
argv = {
"id" : str(post['_id']),
"title" : title,
"subtitle" : escape.xhtml_escape(post['post']['subtitle']),
"poster" : poster,
"link" : "%s/%s/%s/%s.html" % (self.site.domain_root, self.module['setting']['server']['page_view'], post['_id'], title_seo),
}
else:
argv = {
"id" : '{{ id }}',
"title" : '{{ title }}',
"subtitle" : '{{ subtitle }}',
"poster" : '{{ poster }}',
"link" : '{{ link }}'
}
return argv
开发者ID:santatic,项目名称:cinetrongnha.com,代码行数:35,代码来源:main.py
示例4: get
def get(self, note_id):
template_values = {}
if len(note_id) < 8:
raise tornado.web.HTTPError(404)
note_id = decode(note_id)
notes = self.db.query(
"select title,note,rev_num,rev_user_name as name,rev_user_domain as domain"
", revdate from fd_NoteHistory where note_id = %s and rev_status = 0"
" order by rev_num desc", note_id)
if not notes:
raise tornado.web.HTTPError(404)
for i in range(len(notes)):
next_note = {}
if i == len(notes)-1:
next_note['title'] = ''
next_note['note'] = ''
else:
next_note['title'] = notes[i+1].title
next_note['note'] = notes[i+1].note
notes[i].title = textdiff(xhtml_escape(next_note['title']), xhtml_escape(notes[i].title))
note1 = self.br(linkify(next_note['note'], extra_params="target='_blank' rel='nofollow'"))
note2 = self.br(linkify(notes[i].note, extra_params="target='_blank' rel='nofollow'"))
notes[i].note = self.at(textdiff(note1, note2))
notes[i]['rev'] = 0
if i == 0:
notes[i]['rev'] = 1
template_values['notes'] = notes
self.render("notehistory.html", template_values=template_values)
开发者ID:alexzhan,项目名称:dormforge,代码行数:28,代码来源:note.py
示例5: post
def post(self):
"""Post connection form and try to connect with these credentials
"""
incorrect = self.get_secure_cookie('incorrect')
if not incorrect or int(incorrect) < 0:
incorrect = 0
elif int(incorrect) >= max_attemps:
logging.warning('an user is blocked')
self.clear_cookie('user')
self.render('blocked.html', blocked_duration=blocked_duration)
return
getusername = escape.xhtml_escape(self.get_argument('username'))
getpassword = escape.xhtml_escape(self.get_argument('password'))
if login == getusername and password == getpassword:
logging.info('right credentials')
self.set_secure_cookie('user', self.get_argument('username'), expires_days=1)
self.clear_cookie('incorrect')
self.redirect('/')
else:
logging.info('invalid credentials')
incorrect = int(incorrect) + 1
self.set_secure_cookie('incorrect', str(incorrect), expires_days=blocked_duration)
if incorrect >= max_attemps:
logging.warning('an user is now blocked')
self.clear_cookie('user')
self.render('blocked.html', blocked_duration=blocked_duration)
else:
self.render('login.html', failed=True)
开发者ID:emeric254,项目名称:CMangosAdminServer,代码行数:28,代码来源:main.py
示例6: post
def post(self):
id = self.get_argument("id", None)
title = xhtml_escape(self.get_argument("title"))
tep = self.get_argument("info")
code = xhtml_escape(self.get_argument("code"))
pswd = self.get_argument("password")
check = self.get_argument("check", None)
if check != "1984":
self.redirect("/newcode")
return
info = md.convert(tep)
password = hexuserpass(pswd)
slug = "zzzzzzzz"
self.db.execute(
"INSERT INTO entries (password,title,slug,code,info,markdown," "published) VALUES (%s,%s,%s,%s,%s,%s,%s)",
password,
title,
slug,
code,
info,
tep,
datetime.datetime.now(),
)
e = self.db.get("SELECT * FROM entries WHERE slug = %s", slug)
eid = e.id
slug = eid
self.db.execute("UPDATE entries SET slug = %s WHERE id = %s", slug, int(eid))
self.redirect("/" + str(slug))
开发者ID:break123,项目名称:CodeShare,代码行数:30,代码来源:code.py
示例7: post
def post(self):
"""
POST the required parameters to register a TestBox env
* `hostname`
"""
hostname = xhtml_escape(self.get_argument('hostname'))
password = xhtml_escape(self.get_argument('password'))
box_ip = self.request.remote_ip
try:
testbox = yield self.testbox_find(
hostname=hostname,
password=password
)
testbox.hostname = hostname
testbox.password = password
testbox.box_ip = box_ip
testbox.pubkey = self.application.pubkey_content
testbox.updated_at = datetime.now()
except ValueError:
testbox = TestBox(
hostname=hostname,
password=password,
box_ip=box_ip,
pubkey=self.application.pubkey_content,
created_at=datetime.now()
)
res = yield testbox.save()
print(res)
self.set_status(201)
self.success(res.to_son())
开发者ID:Zexi,项目名称:perf-scripts,代码行数:32,代码来源:api.py
示例8: _on_auth
def _on_auth(self, user):
if not user:
self.get_error('/', '10', u'Google auth failed', SITE_NAME)
return
author = User().select(['uid', 'username', 'flag']).find_by_email(user["email"])
if not author:
if CHECK_REG == 1:
usermail = xhtml_escape(user["email"].strip())
username = xhtml_escape(usermail.split('@')[0])
userid = User().user_new_google(username, usermail, '1')
self.session['gnauid'] = userid
self.session['gnaname'] = username
self.session['gnaflag'] = '1'
self.session.save()
self.logaw('reg', u'注册(第一次登录)', '0', '0', '0', '0')
#记录日志(type,des,aid,cid,nid,puid)
self.redirect('/settings')
else:
self.get_error('/', '10', u'系统禁止注册', SITE_NAME)
else:
self.session['gnauid'] = author.uid
self.session['gnaname'] = author.username
self.session['gnaflag'] = author.flag
self.session.save()
self.logaw('login', u'登录', '0', '0', '0', '0')
#记录日志(type,des,aid,cid,nid,puid)
self.redirect(self.get_argument('next', '/'))
开发者ID:amxku,项目名称:toaza.com,代码行数:28,代码来源:x_account.py
示例9: test_get
def test_get(self):
ag_login_id = '0077c686-b0ad-11f8-e050-8a800c5d1877'
self.mock_login_admin()
email = db.get_login_info(ag_login_id)[0]['email']
response = self.get('/ag_edit_participant/', {'email': email})
self.assertEqual(response.code, 200)
# check that all relevant user information is rendered on HTML side
login = db.get_login_by_email(email)
for key, value in login.items():
if not isinstance(key, unicode):
key = key.decode('utf-8')
if key == 'zip':
key = u'zipcode'
elif key == 'ag_login_id':
continue
if not isinstance(value, unicode):
value = value.decode('utf-8')
key = xhtml_escape(key.encode('utf-8'))
value = xhtml_escape(value.encode('utf-8'))
self.assertIn(('</td><td><input type="text" name="%s" id="%s" '
'value="%s"></td></tr>') % (key, key, value),
response.body)
# check what happens if user with email does not exist.
# TODO: we should create a better error message in the handler to be
# displayed, see issue: #115
response = self.get('/ag_edit_participant/?email=notInDB')
self.assertIn('AN ERROR HAS OCCURED!', response.body)
self.assertEqual(response.code, 500)
# TODO: similarly if no email, i.e. user, is given. Issue: #115
response = self.get('/ag_edit_participant/?email=')
self.assertIn('AN ERROR HAS OCCURED!', response.body)
self.assertEqual(response.code, 500)
开发者ID:josenavas,项目名称:labadmin,代码行数:35,代码来源:test_ag_edit_participant.py
示例10: tags_link
def tags_link(self):
tags = self.tags
if not tags:
return ''
links = ['<a href="%s" title="%s" class="tag">%s</a>' % (
tag.permalink, xhtml_escape(tag.title), xhtml_escape(tag.title)) for tag in tags]
return ','.join(links)
开发者ID:messense,项目名称:YaBlog,代码行数:7,代码来源:__init__.py
示例11: post
def post(self):
email = xhtml_escape(self.get_argument("email"))
password = xhtml_escape(self.get_argument("password"))
pool = ThreadPool(processes=1)
pool.apply_async(self.__checkLogin, args=(email, password), callback=self.__onfinish)
pool.close()
开发者ID:matteoluzzi,项目名称:ParkingFinder,代码行数:8,代码来源:LoginHandler.py
示例12: get_netinfo
def get_netinfo(self):
addr = xhtml_escape(common.shell('ip addr'))
routing = xhtml_escape('\n'.join(common.shell('route -n').split("\n")[1:]))
ifaces = OutputFormatter.highlight(xhtml_escape(common.shell('mii-tool 2> /dev/null')))
lan = appconfig.get()['net']
sangoma = common.shell("wanrouter status")
return {'addr': addr, 'routing': routing, 'lan': lan, 'ifaces': ifaces, 'sangoma': sangoma}
开发者ID:guyt101z,项目名称:fsui,代码行数:9,代码来源:httphandlers.py
示例13: block_code
def block_code(self, code, language):
# Don't forget about escaping
code = ignore_trailing_newlines(xhtml_escape(code))
if language:
language = xhtml_escape(language)
klass = ' class="language-{0}"'.format(language)
else:
klass = ""
return "<pre><code{0}>{1}</code></pre>\n".format(klass, code)
开发者ID:border-radius,项目名称:bnw,代码行数:9,代码来源:markdown.py
示例14: post
def post(self):
username = xhtml_escape(self.get_argument("username"))
email = xhtml_escape(self.get_argument("email"))
password = xhtml_escape(self.get_argument("password"))
conf_pass = xhtml_escape(self.get_argument("confirmPassword"))
#Thread incaricato di gesitire la scrittura sul db
pool = ThreadPool(processes=1)
pool.apply_async(self.__checkDuplicates, args=(username, email, password), callback=self.__onfinish)
pool.close()
开发者ID:matteoluzzi,项目名称:ParkingFinder,代码行数:11,代码来源:RegisterHandler.py
示例15: get_scores
def get_scores(self):
scores = {}
for socket in self.sockets:
name = socket.name
if name in self.game.scores:
scores[xhtml_escape(name)] = self.game.scores[name]
else:
scores[xhtml_escape(name)] = []
for (name, score) in self.game.scores.items():
if not xhtml_escape(name) in scores:
scores[xhtml_escape(name) + " (ABSENT)"] = score
return scores
开发者ID:captainstompy,项目名称:websockettau,代码行数:12,代码来源:lobby_game.py
示例16: show_flash
def show_flash(self):
err = self.get_secure_cookie('e')
info = self.get_secure_cookie('i')
s = ''
if err:
s += '<div class="error">%s</div>' % (xhtml_escape(err),)
self.clear_cookie('e')
if info:
s += '<div class="info">%s</div>' % (xhtml_escape(info),)
self.clear_cookie('i')
return s
开发者ID:sloppyfocus,项目名称:chronologic,代码行数:12,代码来源:handlers.py
示例17: write_error
def write_error(self, status_code, **kwargs):
if hasattr(self, "error_message"):
if isinstance(self.error_message, BaseException):
import traceback
self.write("<html><body><pre>%s</pre></body></html>" %
xhtml_escape(''.join(traceback.format_exc())))
else:
self.write("<html><body>Error: %s</body></html>" %
xhtml_escape(self.error_message))
else:
super(HandlerBase, self).write_error(status_code, **kwargs)
开发者ID:2php,项目名称:veles,代码行数:12,代码来源:forge_server.py
示例18: post
def post(self):
result = {}
try:
tmp_file = self.get_argument("tmp_file")
result["status"] = os.path.isfile(tmp_file)
if result["status"]:
result["message"] = "上传成功"
self.write(json.dumps(result))
self.finish()
file_info = {
"nickname" : xhtml_escape(self.get_argument("nickname")),
"category" : self.get_argument("category"),
"intro" : xhtml_escape(self.get_argument("intro")),
"uploader" : self.get_secure_cookie("username"),
"tmp_file" : tmp_file,
}
category = self.get_argument("category")
sub_category = self.get_arguments("sub_category")
file_info["cid"] = sub_category[-1]
if category == "common":
# 常用分类,需要记录pid
file_info["pid"] = sub_category[0]
if category == "book":
# 图书类,需要作者
file_info["author"] = self.get_argument("author", "anonymous")
elif category == "magazine":
# 杂志类,需要出版社,刊号
file_info["publisher"] = xhtml_escape(
self.get_argument("publisher", "unknown"))
file_info["issue"] = xhtml_escape(
self.get_argument("issue", "unknown"))
file_path = {
"static_path" : self.application.settings["static_path"],
"temp_path" : self.application.settings["temp_path"]
}
pool = multiprocessing.Pool(processes=8)
pool.apply_async(Upload, (file_info, file_path))
pool.close()
pool.join()
else:
result["message"] = "附件已丢失...请联系网站管理员或重新上传"
self.write(json.dumps(result))
self.finish()
return
except Exception as e:
print e
# result["status"] = False
# result["message"] = e
self.finish()
开发者ID:490003773,项目名称:Keda-Library,代码行数:50,代码来源:uploadHandler.py
示例19: post
def post(self):
if self.session['gnaflag'] <> '675':
raise tornado.web.HTTPError(404)
return
node_nName = unicode(xhtml_escape(self.get_argument('nName', '').strip()))
node_nUrl = clear2nbsp(xhtml_escape(self.get_argument('nUrl', '').strip().lower()))
node_nDes = unicode(xhtml_escape(self.get_argument('nDes', '').strip()))
node_nType = xhtml_escape(self.get_argument('nType', 'N'))
node_subhead = int(self.get_argument('subhead', '0'))
nid = int(self.get_argument('nid','0'))
if nid:
if node_nName and node_nUrl:
if node_nType == 'N':
if not node_subhead:
self.get_error('javascript:history.go(-1);','10',u'分类不能为空','toaza.com')
return
Node().node_admin_update(node_nName,node_nUrl,node_nDes,node_nType,node_subhead,nid)
self.logaw('admin',u'修改节点','0','0',nid,'0') #记录日志(type,des,aid,cid,nid,puid)
self.get_error('javascript:history.go(-2);','10',u'修改成功','toaza.com')
else:
self.get_error('javascript:history.go(-1);','10',u'名字和url不能为空','toaza.com')
return
else:
if node_nName and node_nUrl:
if node_nType == 'N':
if not node_subhead:
self.get_error('javascript:history.go(-1);','10',u'分类不能为空','toaza.com')
return
check_node_url = Node().find_by_nType_and_nUrl_and_nName('N',node_nUrl,node_nName)
if not check_node_url:
nodeid = Node().node_admin_new(node_nName,node_nUrl,node_nDes,node_nType,node_subhead)
self.logaw('admin',u'添加节点','0','0',nodeid,'0') #记录日志(type,des,aid,cid,nid,puid)
if nodeid:
if node_nType == 'N':
self.get_error('/zzginoa/nodes?op=index&nType=N','10',u'节点添加成功','toaza.com')
return
else:
self.get_error('/zzginoa/nodes?op=index&nType=C','10',u'分类添加成功','toaza.com')
return
else:
self.get_error('javascript:history.go(-1);','10',u'添加出错','toaza.com')
return
else:
self.get_error('javascript:history.go(-1);','10',u'节点名称、Url已经存在','toaza.com')
return
else:
self.get_error('javascript:history.go(-1);','10',u'名字、url不能为空','toaza.com')
return
开发者ID:amxku,项目名称:toaza.com,代码行数:50,代码来源:zz_main.py
示例20: post
def post(self,id):
if self.check_login(id):
id = int(id)
url = '/detail/' + str(id)
title = xhtml_escape(self.get_argument('title', ''))
poster = xhtml_escape(self.get_argument('poster', ''))
password = xhtml_escape(self.get_argument('password', ''))
type = xhtml_escape(self.get_argument('syntax', 'other'))
content = xhtml_escape(self.get_argument('content', ''))
time = fmt_time()
Post.modify(id, title, poster, type, content, time, password)
self.redirect(url)
else:
self.redirect('/detail/' + str(id))
开发者ID:carriercomm,项目名称:Pastebin-12,代码行数:14,代码来源:user.py
注:本文中的tornado.escape.xhtml_escape函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论