本文整理匯總了Python中katapult.requests.RequestHelper.write_text方法的典型用法代碼示例。如果您正苦於以下問題:Python RequestHelper.write_text方法的具體用法?Python RequestHelper.write_text怎麽用?Python RequestHelper.write_text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類katapult.requests.RequestHelper
的用法示例。
在下文中一共展示了RequestHelper.write_text方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from katapult.requests import RequestHelper [as 別名]
# 或者: from katapult.requests.RequestHelper import write_text [as 別名]
def get(self):
helper = RequestHelper(self)
try:
if not users.is_current_user_admin():
helper.error(403, "admin required")
return
oauth_token = self.request.get("oauth_token")
if not oauth_token:
# initial request, I store the request token key/secret as cookies and redirect to twitter's auth page
request_token, auth_url = TwitterConnector.get_request_token_and_auth_url()
logging.debug("request token key:%s, secret:%s" % (request_token.key, request_token.secret))
helper.set_cookie("%s=%s; path=/" % (self._rtoken_key_cookie, request_token.key))
helper.set_cookie("%s=%s; path=/" % (self._rtoken_secret_cookie, request_token.secret))
helper.write_text("redirecting request token %s to %s" % (request_token.to_string(), auth_url))
self.redirect(auth_url)
else:
# post verification request
key = self.request.cookies.get(self._rtoken_key_cookie, None)
secret = self.request.cookies.get(self._rtoken_secret_cookie, None)
if not (key and secret):
helper.error(400, "key and secret not stored as cookies")
return
access_token = TwitterConnector.get_access_token(key, secret)
token_string = access_token.to_string()
ConfigurationAccessor.update(twitter_access_token=token_string)
helper.write_text("saved access token %s" % token_string)
except Exception, e:
msg = traceback.print_exc()
helper.error(500, msg)