本文整理汇总了Python中database.User.verify_user_openID方法的典型用法代码示例。如果您正苦于以下问题:Python User.verify_user_openID方法的具体用法?Python User.verify_user_openID怎么用?Python User.verify_user_openID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.User
的用法示例。
在下文中一共展示了User.verify_user_openID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_user_info
# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import verify_user_openID [as 别名]
def get_user_info(self, code):
client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL)
r = client.request_access_token(code)
access_token = r.access_token
expires_in = r.expires_in
print r.access_token, r.expires_in
client.set_access_token(access_token, expires_in)
uid = client.get.account__get_uid().uid
print uid
user = User.verify_user_openID(accountType=User.USER_TYPE_SINA_WEIBO, accountID=uid)
if not user:
user_info = client.get.users__show(uid=uid)
user = User.new(
username="%s_%s" % (User.USER_TYPE_SINA_WEIBO, uid),
accountType=User.USER_TYPE_SINA_WEIBO,
accountID=uid,
)
user.screen_name = user_info.screen_name
user.gender = user_info.gender
user.headPortrait_url = user_info.profile_image_url # avatar_large?
print user_info
user.openIDinfo = user_info
else:
print "old user"
if user.last_login == None:
user.bonus_notification = 1
else:
last_login_date = datetime.fromtimestamp(user.last_login)
if last_login_date.date() < datetime.today().date():
user.bonus_notification = 1
user.last_login = int(time.time())
self.got_user_info(uid, user)
示例2: _process_data
# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import verify_user_openID [as 别名]
def _process_data(self, data,method):
request_type = method
if request_type == 'payments_get_items':
item_id = data["credits"]['order_info']
item = Commodity.find(commodity_id = int(item_id))
itemInfo = {}
itemInfo['item_id'] = item_id
itemInfo['title'] = item.title
itemInfo['price'] = item.price
itemInfo['description'] = item.description
itemInfo['image_url'] = item.image_url
response = {"content":[itemInfo], "method":request_type}
elif request_type == "payments_status_update":
order_details = json.loads(data['credits']['order_details'])
item_data = order_details['items'][0]['data']
if "modified" in item_data:
earned_currency_order = item_data['modified']
else:
earned_currency_order = None
current_order_status = order_details["status"]
if current_order_status == "placed":
if earned_currency_order != None:
print earned_currency_order
# product = earned_currency_order['product']
# product_title = earned_currency_order['product_title']
# product_amount = earned_currency_order['product_amount']
# credits_amount = earned_currency_order['credits_amount']
client_id = data['user_id']
items = order_details['items']
client = User.verify_user_openID( accountType = User.USER_TYPE_FACEBOOK,
accountID = client_id)
for item in items:
commodity = Commodity.find(commodity_id = int(item["item_id"]))
client.update_attr('asset', commodity.money)
self.save_order(client_id, order_details)
next_order_status = "settled"
response = {
"content" : {
"status":next_order_status,
"order_id":order_details['order_id']
},
"method" : request_type
}
elif current_order_status == "disputed":
raise Exception("disputed")
pass
elif current_order_status == "refunded":
raise Exception("refunded")
elif current_order_status == "settled":
response = {}
else:
raise Exception(request_type)
print json.dumps(response)
self.finish(json.dumps(response))
示例3: _handle_check_permission
# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import verify_user_openID [as 别名]
def _handle_check_permission(self, response):
permissions = json.loads(response.body)["data"][0]
if "user_status" in permissions and permissions["user_status"] == 1 and \
"publish_actions" in permissions and permissions["publish_actions"] == 1 and \
"publish_stream" in permissions and permissions["publish_stream"] == 1:
user = User.verify_user_openID(accountType = User.USER_TYPE_FACEBOOK,
accountID = self.payload["user_id"])
if not user:
self.get_user_info(self.payload)
else:
self._login_user(user)
else:
self.finish("<script>top.location.href='" + auth_url + "'</script>")