本文整理匯總了Python中werkzeug.url_encode方法的典型用法代碼示例。如果您正苦於以下問題:Python werkzeug.url_encode方法的具體用法?Python werkzeug.url_encode怎麽用?Python werkzeug.url_encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類werkzeug
的用法示例。
在下文中一共展示了werkzeug.url_encode方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _edi_paypal_url
# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import url_encode [as 別名]
def _edi_paypal_url(self, cr, uid, ids, field, arg, context=None):
res = dict.fromkeys(ids, False)
for order in self.browse(cr, uid, ids, context=context):
if order.order_policy in ('prepaid', 'manual') and \
order.company_id.paypal_account and order.state != 'draft':
params = {
"cmd": "_xclick",
"business": order.company_id.paypal_account,
"item_name": order.company_id.name + " Order " + order.name,
"invoice": order.name,
"amount": order.amount_total,
"currency_code": order.pricelist_id.currency_id.name,
"button_subtype": "services",
"no_note": "1",
"bn": "OpenERP_Order_PayNow_" + order.pricelist_id.currency_id.name,
}
res[order.id] = "https://www.paypal.com/cgi-bin/webscr?" + url_encode(params)
return res
示例2: recaptcha_html
# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import url_encode [as 別名]
def recaptcha_html(self, public_key):
html = current_app.config.get('RECAPTCHA_HTML')
if html:
return Markup(html)
params = current_app.config.get('RECAPTCHA_PARAMETERS')
script = RECAPTCHA_SCRIPT
if params:
script += u'?' + url_encode(params)
attrs = current_app.config.get('RECAPTCHA_DATA_ATTRS', {})
attrs['sitekey'] = public_key
snippet = u' '.join([u'data-%s="%s"' % (k, attrs[k]) for k in attrs])
return Markup(RECAPTCHA_TEMPLATE % (script, snippet))
示例3: _validate_recaptcha
# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import url_encode [as 別名]
def _validate_recaptcha(self, response, remote_addr):
"""Performs the actual validation."""
try:
private_key = current_app.config['RECAPTCHA_PRIVATE_KEY']
except KeyError:
raise RuntimeError("No RECAPTCHA_PRIVATE_KEY config set")
data = url_encode({
'secret': private_key,
'remoteip': remote_addr,
'response': response
})
http_response = http.urlopen(RECAPTCHA_VERIFY_SERVER, to_bytes(data))
if http_response.code != 200:
return False
json_resp = json.loads(to_unicode(http_response.read()))
if json_resp["success"]:
return True
for error in json_resp.get("error-codes", []):
if error in RECAPTCHA_ERROR_CODES:
raise ValidationError(RECAPTCHA_ERROR_CODES[error])
return False
示例4: _build_debug_response
# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import url_encode [as 別名]
def _build_debug_response(self):
result = None
try:
query = request.params
query.update({'debug': u''})
url = '/web?' + werkzeug.url_encode(query)
result = redirect_with_hash(url)
except Exception as ex:
_logger.error(self._error_response.format(ex))
return result
# ------------------------ LONG CHARACTER STRING --------------------------
示例5: url_rewrite
# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import url_encode [as 別名]
def url_rewrite(url=None, **kwargs):
scheme, netloc, path, query, fragments = urlsplit(url or request.url)
params = url_decode(query)
for key, value in kwargs.items():
params.setlist(key,
value if isinstance(value, (list, tuple)) else [value])
return Markup(urlunsplit((scheme, netloc, path, url_encode(params),
fragments)))
示例6: url_add
# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import url_encode [as 別名]
def url_add(url=None, **kwargs):
scheme, netloc, path, query, fragments = urlsplit(url or request.url)
params = url_decode(query)
for key, value in kwargs.items():
if value not in params.getlist(key):
params.add(key, value)
return Markup(urlunsplit((scheme, netloc, path, url_encode(params),
fragments)))
示例7: url_del
# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import url_encode [as 別名]
def url_del(url=None, *args, **kwargs):
scheme, netloc, path, query, fragments = urlsplit(url or request.url)
params = url_decode(query)
for key in args:
params.poplist(key)
for key, value in kwargs.items():
lst = params.poplist(key)
if str(value) in lst:
lst.remove(str(value))
params.setlist(key, lst)
return Markup(urlunsplit((scheme, netloc, path, url_encode(params),
fragments)))
示例8: _get_auth_link_wo
# 需要導入模塊: import werkzeug [as 別名]
# 或者: from werkzeug import url_encode [as 別名]
def _get_auth_link_wo(self, provider=None):
if not provider:
provider = request.env(user=1).ref('weodoo.provider_third')
return_url = request.httprequest.url_root + 'auth_oauth/signin3rd'
state = self.get_state(provider)
self._deal_state_r(state)
params = dict(
response_type='token',
client_id=provider['client_id'],
redirect_uri=return_url,
scope=provider['scope'],
state=json.dumps(state),
)
return "%s?%s" % (provider['auth_endpoint'], werkzeug.url_encode(params))