本文整理汇总了Python中tornado.escape.url_escape函数的典型用法代码示例。如果您正苦于以下问题:Python url_escape函数的具体用法?Python url_escape怎么用?Python url_escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url_escape函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post
def post(self,sbjct_id):
all_sbjcts = StuSbjct().getSbjcts()
crrnt_sbjct = self.getCrrntSbjct(all_sbjcts,sbjct_id) if all_sbjcts else ()
name = self.get_argument("name",default='')
psswd = self.get_argument("psswd",default='')
if name and psswd:
re = Stu(name=name,psswd=psswd,ipaddr=self.request.remote_ip).isRgstr()
# print(self.request.remote_ip)
if re:
self.set_secure_cookie('name',str(re[1]))
self.set_secure_cookie('id',str(re[0]))
self.set_secure_cookie('usertype',str(re[3]))
if crrnt_sbjct and (crrnt_sbjct[3] or re[3]):
all_answrs = StuAnswr().getAnswrs(crrnt_sbjct[0])
elif crrnt_sbjct:
all_answrs = StuAnswr().getSelfAnswr(crrnt_sbjct[0],int(re[0]))
else:
all_answrs = []
all_hlp_self = self.getHlps()
self.render('index.html',dict(stu_id=re[0],name=name,usertype=re[3],
all_sbjcts=all_sbjcts,crrnt_sbjct=crrnt_sbjct,info='',
all_answrs=all_answrs,all_hlp_self=all_hlp_self))
else:
self.redirect('/?info=' + url_escape("登录失败!"))
else:
self.redirect('/?info=' + url_escape("登录失败!"))
开发者ID:cloveses,项目名称:stir-mentality,代码行数:26,代码来源:manage.py
示例2: set_blink
def set_blink(self, message, type="info"):
"""
Sets the blink, a one-time transactional message that is shown on the
next page load
"""
self.set_cookie("blink_message", escape.url_escape(message), httponly=True)
self.set_cookie("blink_type", escape.url_escape(type), httponly=True)
开发者ID:jstacoder,项目名称:oz,代码行数:7,代码来源:middleware.py
示例3: _render
def _render(self, login_error=None, username=None):
return self.render_template('login.html',
next=url_escape(self.get_argument('next', default='')),
repourl=url_escape(self.get_argument('repourl', default='')),
username=username,
login_error=login_error,
)
开发者ID:BertrandNOEL,项目名称:everware,代码行数:7,代码来源:authenticator.py
示例4: test_connect
def test_connect(c, s, a, b):
future = c.submit(lambda x: x + 1, 1)
x = c.submit(slowinc, 1, delay=1, retries=5)
yield future
http_client = AsyncHTTPClient()
for suffix in ['info/main/workers.html',
'info/worker/' + url_escape(a.address) + '.html',
'info/task/' + url_escape(future.key) + '.html',
'info/main/logs.html',
'info/logs/' + url_escape(a.address) + '.html',
'info/call-stack/' + url_escape(x.key) + '.html',
'info/call-stacks/' + url_escape(a.address) + '.html',
'json/counts.json',
'json/identity.json',
'json/index.html',
'individual-plots.json',
]:
response = yield http_client.fetch('http://localhost:%d/%s'
% (s.services['bokeh'].port, suffix))
assert response.code == 200
body = response.body.decode()
if suffix.endswith('.json'):
json.loads(body)
else:
assert xml.etree.ElementTree.fromstring(body) is not None
assert not re.search("href=./", body) # no absolute links
开发者ID:tomMoral,项目名称:distributed,代码行数:26,代码来源:test_scheduler_bokeh_html.py
示例5: work_link
def work_link(ID):
"""Return an HTML link for the work designed by ID (using /serie/
for a serie, /movie/ for a movie and /episode/ for an episode)"""
if ID[0] != '"':
# Movie
res = re.search('^(.+) \(([0-9]{4})[^\)]*\)', ID)
if res:
title = escape(res.group(1))
year = escape(res.group(2))
return ('<a href="/movie/%s">%s (%s)</a>' % (url_escape(ID), title, year))
else:
return ('Invalid movie ID: %s' % escape(ID))
elif ID.find('{') != -1:
# Episode
res = re.search('^"(.+)" \(([0-9]{4})[^\)]*\) \{([^\(]*)(\(#([0-9]{1,3})\.([0-9]{1,3})\))?\}', ID)
if res:
title = escape(res.group(1))
year = escape(res.group(2))
epi_name = escape(res.group(3))
season = escape(res.group(5) or '')
epi_num = escape(res.group(6) or '')
return ('<a href="/episode/%s">%s (%s) %sx%s: %s</a>' % (url_escape(ID), title, year, season, epi_num, epi_name))
else:
return ('Invalid episode ID: %s' % escape(ID))
else:
# Serie
res = re.search('"(.+)" \(([0-9]{4})[^\)]*\)', ID)
if res:
title = escape(res.group(1))
year = escape(res.group(2))
return ('<a href="/serie/%s">%s (%s)</a>' % (url_escape(ID), title, year))
else:
return ('Invalid serie ID: %s' % escape(ID))
开发者ID:acieroid,项目名称:imdb,代码行数:33,代码来源:utils.py
示例6: post
def post(self):
username = self.get_argument("email", "").strip().lower()
password = self.get_argument("newpass", "")
info = {}
for info_column in ("name", "affiliation", "address", "phone"):
hold = self.get_argument(info_column, None)
if hold:
info[info_column] = hold
created = False
try:
created = User.create(username, password, info)
except QiitaDBDuplicateError:
msg = "Email already registered as a user"
if created:
info = created.info
try:
send_email(username, "QIITA: Verify Email Address", "Please "
"click the following link to verify email address: "
"%s/auth/verify/%s?email=%s"
% (qiita_config.base_url, info['user_verify_code'],
url_escape(username)))
except:
msg = ("Unable to send verification email. Please contact the "
"qiita developers at <a href='mailto:qiita-help"
"@gmail.com'>[email protected]</a>")
self.redirect(u"/?level=danger&message=" + url_escape(msg))
return
self.redirect(u"/")
else:
error_msg = u"?error=" + url_escape(msg)
self.redirect(u"/auth/create/" + error_msg)
开发者ID:DarcyMyers,项目名称:qiita,代码行数:33,代码来源:auth_handlers.py
示例7: post
def post(self):
try:
username = self.get_argument('username')
# TODO: replace with JWT from OpenID Connect
auth = self.get_argument('auth')
except tornado.web.MissingArgumentError:
self.write('Must specify username and auth.')
return
user_id = yield self.db.retrieve_user_id_from_username(username)
if user_id is None:
self.redirect('/login?error={0}'
.format(escape.url_escape('Unknown username or password.')))
else:
user_auth = yield self.db.retrieve_user_auth(user_id)
hashed_auth = yield pool.submit(
bcrypt.hashpw, auth.encode('utf-8'), user_auth.encode('utf-8'))
if user_auth == hashed_auth:
session_auth = yield self.db.retrieve_user_session_auth(user_id)
self.set_secure_cookie('session_auth', session_auth,
expires_days=SESSION_MAX_AGE_DAYS)
self.redirect('/')
else:
self.redirect('/login?error={0}'
.format(escape.url_escape(
'Unknown username or password.')))
开发者ID:mhmurray,项目名称:cloaca,代码行数:28,代码来源:handlers.py
示例8: send_mail_reset
def send_mail_reset(to, token, name):
subject = u'子曰--密码重置'
html = (u"<html><head></head><body>"
u"<p>" + name + u",您对密码进行了重置,请您点击下面链接完成密码重置操作!</p><br>"
u"<p><a href='http://www.afewords.com/check?type=reset&email=" + url_escape(to)+ u"&token="+ token +u"'>重置链接</a></p>"
u"<p>或者将链接复制至地址栏完成密码重置:http://www.afewords.com/check?type=reset&email="+url_escape(to)+"&token=" + token + u"</p>"
u"<body></html>")
return send_mail(to, subject, html)
开发者ID:deju,项目名称:afw_old,代码行数:8,代码来源:AF_Tool.py
示例9: _render
def _render(self, login_error=None, username=None):
return self.render_template(
"login.html",
next=url_escape(self.get_argument("next", default="")),
repourl=url_escape(self.get_argument("repourl", default="")),
username=username,
login_error=login_error,
)
开发者ID:RPraneetha,项目名称:everware,代码行数:8,代码来源:authenticator.py
示例10: send_mail_reg
def send_mail_reg(to, token, name):
subject = u'子曰--验证注册'
html = (u"<html><head></head><body>"
u"<p>" + name + u",欢迎您注册子曰,请您点击下面链接进行邮箱验证操作!</p>"
u"<br>"
u"<p><a href='http://www.afewords.com/check?email="+ url_escape(to)+ u"&token=" + token + u"'>验证链接</a></p><br>"
u"<p>或者将链接复制至地址栏完成邮箱激活:http://www.afewords.com/check?email="+url_escape(to)+"&token=" + token + u"</p>"
u"</body></html>")
return send_mail(to, subject, html)
开发者ID:deju,项目名称:afw_old,代码行数:9,代码来源:AF_Tool.py
示例11: delete_attachment
def delete_attachment(self, doc, attachment_name):
'''Delete a named attachment to the specified doc.
The doc shall be a dict, at least with the keys: _id and _rev'''
if '_rev' not in doc or '_id' not in doc:
raise KeyError('Missing id or revision information in doc')
url = '/{0}/{1}/{2}?rev={3}'.format(self.db_name,
url_escape(doc['_id']), url_escape(attachment_name),
doc['_rev'])
return self._http_delete(url)
开发者ID:dgquintas,项目名称:my-code-samples,代码行数:9,代码来源:couch.py
示例12: send_file
def send_file(file_path, dashboard_name, handler):
'''
Posts a file to the Jupyter Dashboards Server to be served as a dashboard
:param file_path: The path of the file to send
:param dashboard_name: The dashboard name under which it should be made
available
'''
# Make information about the request Host header available for use in
# constructing the urls
segs = handler.request.host.split(':')
hostname = segs[0]
if len(segs) > 1:
port = segs[1]
else:
port = ''
protocol = handler.request.protocol
# Treat empty as undefined
dashboard_server = os.getenv('DASHBOARD_SERVER_URL')
if dashboard_server:
dashboard_server = dashboard_server.format(protocol=protocol,
hostname=hostname, port=port)
upload_url = url_path_join(dashboard_server, UPLOAD_ENDPOINT,
escape.url_escape(dashboard_name, False))
with open(file_path, 'rb') as file_content:
headers = {}
token = os.getenv('DASHBOARD_SERVER_AUTH_TOKEN')
if token:
headers['Authorization'] = 'token {}'.format(token)
result = requests.post(upload_url, files={'file': file_content},
headers=headers, timeout=60,
verify=not skip_ssl_verification())
if result.status_code >= 400:
raise web.HTTPError(result.status_code)
# Redirect to link specified in response body
res_body = result.json()
if 'link' in res_body:
redirect_link = res_body['link']
else:
# Compute redirect link using environment variables
# First try redirect URL as it might be different from internal upload URL
redirect_server = os.getenv('DASHBOARD_REDIRECT_URL')
if redirect_server:
redirect_root = redirect_server.format(hostname=hostname,
port=port, protocol=protocol)
else:
redirect_root = dashboard_server
redirect_link = url_path_join(redirect_root, VIEW_ENDPOINT, escape.url_escape(dashboard_name, False))
handler.redirect(redirect_link)
else:
access_log.debug('Can not deploy, DASHBOARD_SERVER_URL not set')
raise web.HTTPError(500, log_message='No dashboard server configured')
开发者ID:jupyter-incubator,项目名称:dashboards_bundlers,代码行数:54,代码来源:__init__.py
示例13: params
def params(param):
key, value = param
if value is None:
return
key = escape.url_escape(str(key))
value = escape.url_escape(str(value))
self.log.info((key, value))
return '%s=%s' % (key, value)
开发者ID:BrainsInJars,项目名称:Queen-Bee,代码行数:11,代码来源:__init__.py
示例14: test_url_escape_quote_plus
def test_url_escape_quote_plus(self):
unescaped = '+ #%'
plus_escaped = '%2B+%23%25'
escaped = '%2B%20%23%25'
self.assertEqual(url_escape(unescaped), plus_escaped)
self.assertEqual(url_escape(unescaped, plus=False), escaped)
self.assertEqual(url_unescape(plus_escaped), unescaped)
self.assertEqual(url_unescape(escaped, plus=False), unescaped)
self.assertEqual(url_unescape(plus_escaped, encoding=None),
utf8(unescaped))
self.assertEqual(url_unescape(escaped, encoding=None, plus=False),
utf8(unescaped))
开发者ID:YoungLeeNENU,项目名称:tornado,代码行数:12,代码来源:escape_test.py
示例15: recurse
def recurse(obj,prefix=''):
if isinstance(obj,dict):
for k in obj:
recurse(obj[k],prefix+'['+k+']')
elif isinstance(obj,list):
for i,v in enumerate(obj):
if isinstance(v,(dict,list)):
recurse(v,prefix+'[%d]'%i)
else:
recurse(v,prefix+'[]')
else:
ret.append(url_escape(prefix)+'='+url_escape(str(obj)))
开发者ID:dsschult,项目名称:file_catalog,代码行数:12,代码来源:urlargparse.py
示例16: _star
def _star(self, notebook_name, note_name, star, redir=True):
starred = self.get_starred()
full_name = u'%s/%s' % (notebook_name, note_name)
if star == 'set' and full_name not in starred:
starred.append(full_name)
elif star == 'unset' and full_name in starred:
starred.remove(full_name)
self.set_cookie('starred_notes',
b64encode(','.join(starred).encode('utf8')),
expires_days=365)
if redir:
self.redirect('/%s/%s' % (url_escape(notebook_name).replace('#', '%23'), url_escape(note_name).replace('#', '%23')))
开发者ID:01-,项目名称:magpie,代码行数:12,代码来源:note.py
示例17: post
def post(self):
username = self.get_argument("email", "").strip().lower()
password = self.get_argument("newpass", "")
info = {}
for info_column in ("name", "affiliation", "address", "phone"):
hold = self.get_argument(info_column, None)
if hold:
info[info_column] = hold
created = False
try:
created = User.create(username, password, info)
except QiitaDBDuplicateError:
msg = "Email already registered as a user"
if created:
info = created.info
try:
# qiita_config.base_url doesn't have a / at the end, but the
# qiita_config.portal_dir has it at the beginning but not at
# the end. This constructs the correct URL
url = qiita_config.base_url + qiita_config.portal_dir
send_email(username, "QIITA: Verify Email Address", "Please "
"click the following link to verify email address: "
"%s/auth/verify/%s?email=%s\n\nBy clicking you are "
"accepting our term and conditions: "
"%s/iframe/?iframe=qiita-terms"
% (url, info['user_verify_code'],
url_escape(username), url))
except Exception:
msg = ("Unable to send verification email. Please contact the "
"qiita developers at <a href='mailto:qiita-help"
"@gmail.com'>[email protected]</a>")
self.redirect(u"%s/?level=danger&message=%s"
% (qiita_config.portal_dir, url_escape(msg)))
return
msg = ("<h3>User Successfully Created</h3><p>Your Qiita account "
"has been successfully created. An email has been sent to "
"the email address you provided. This email contains "
"instructions on how to activate your account.</p>"
"<p>If you don't receive your activation email within a "
"couple of minutes, check your spam folder. If you still "
"don't see it, send us an email at <a "
"href=\"mailto:[email protected]\">[email protected]"
"</a>.</p>")
self.redirect(u"%s/?level=success&message=%s" %
(qiita_config.portal_dir, url_escape(msg)))
else:
error_msg = u"?error=" + url_escape(msg)
self.redirect(u"%s/auth/create/%s"
% (qiita_config.portal_dir, error_msg))
开发者ID:antgonza,项目名称:qiita,代码行数:52,代码来源:auth_handlers.py
示例18: person_info
def person_info(t, person, ID, admin):
(fname, lname, num) = person
res = ('<a href="/person/%s/%s/%s">%s %s</a>' %
(url_escape(fname), url_escape(lname), url_escape(num),
url_escape(fname), url_escape(lname)))
if admin:
res += (' (<a href="/admin/delete/%s/%s/%s/%s/%s">delete</a>)' %
(t, url_escape(fname), url_escape(lname), url_escape(num),
url_escape(ID)))
return res
开发者ID:acieroid,项目名称:imdb,代码行数:10,代码来源:utils.py
示例19: run
def run(self):
book = self.book
lock = self.lock
whoToAsk = _setWhoToAsk(self.user, self.whoToAsk, self.book, self.connectAll, self.maxConnection)
http_client = tornado.httpclient.HTTPClient()
_body = 'userName=' + escape.url_escape(self.user.name)
_body += '&userPubKey=' + escape.url_escape(self.user.pubKey)
_body += '&host=' + escape.url_escape(self.user.host)
_body += '&port=' + escape.url_escape(str(self.user.port))
_body += '&invitation=' + escape.url_escape(self.user.invitation if self.user.invitation is not None else ' ')
_body += '&approverID=' + escape.url_escape(self.user.approverID if self.user.approverID is not None else ' ')
_body += '&bookID=' + escape.url_escape(self.book.getID())
_body += '&password=' + escape.url_escape(_authCode(self.user))
for user in whoToAsk:
try:
address = 'http://' + str(user.host) + ':' + str(user.port)
if self.askMember:
response = http_client.fetch(address + '/members', method = 'POST', body = _body)
members = escape.json_decode(response.body)
_updateMembers(members, self.user, book, lock, address)
if self.askAction:
response = http_client.fetch(address + '/versions', method = 'POST', body = _body)
versions = escape.json_decode(response.body)
_updateActions(versions, self.user, book, lock, address)
except tornado.httpclient.HTTPError as e:
#todo: log
print("Error:" + str(e))
pass
except ValueError:
print('ValueError')
开发者ID:aphlysia,项目名称:ahiru,代码行数:31,代码来源:manager.py
示例20: save_attachment
def save_attachment(self, doc, attachment):
'''Save an attachment to the specified doc.
The attachment shall be a dict with keys: `mimetype`, `name`, `data`.
The doc shall be a dict, at least having the key `_id`, and if doc is
existing in the database, it shall also contain the key `_rev`'''
if any(key not in attachment for key in ('mimetype', 'name', 'data')):
raise KeyError('Attachment dict is missing one or more required '
'keys')
url = '/{0}/{1}/{2}{3}'.format(self.db_name, url_escape(doc['_id']),
url_escape(attachment['name']),
'?rev={0}'.format(doc['_rev']) if '_rev' in doc else '')
headers = {'Content-Type': attachment['mimetype']}
body = attachment['data']
return self._http_put(url, body, headers=headers)
开发者ID:dgquintas,项目名称:my-code-samples,代码行数:14,代码来源:couch.py
注:本文中的tornado.escape.url_escape函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论