本文整理匯總了Python中API.APIPermissions.get_element_key_by_ref方法的典型用法代碼示例。如果您正苦於以下問題:Python APIPermissions.get_element_key_by_ref方法的具體用法?Python APIPermissions.get_element_key_by_ref怎麽用?Python APIPermissions.get_element_key_by_ref使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類API.APIPermissions
的用法示例。
在下文中一共展示了APIPermissions.get_element_key_by_ref方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __check_app_access
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import get_element_key_by_ref [as 別名]
def __check_app_access(redir = False):
authed_user = auth.get_current_user()
if authed_user is None:
return __unauthed_response(redir)
else:
elem = ps.get_element_key_by_ref('canLogIn')
if elem is not None:
user_key = ps.get_user_key_by_id(authed_user.user_id())
if user_key is not None:
perm = ps.get_user_element_permissions(user_key, elem)
if perm is not None:
if perm.access:
return None
return __not_signed_up_response(redir)
示例2: signup_handler
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import get_element_key_by_ref [as 別名]
def signup_handler(request):
authed_user = auth.get_current_user()
if authed_user is None:
return __unauthed_response()
user_key = ps.get_user_key_by_id(authed_user.user_id())
if user_key is None:
user_key = ps.add_user(authed_user)
response_part = {
'success' : False
}
try:
file_req = json.loads(request.raw_post_data)
except ValueError:
response_part.update({'error' : 'Invalid request payload.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
if 'action' not in file_req:
response_part.update({'error' : 'Incomplete request.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
elem_key = ps.get_element_key_by_ref('canLogIn')
if elem_key is None:
elem_key = ps.add_element('canLogIn')
user_elem = ps.get_user_element_permissions(user_key, elem_key)
if user_elem is not None:
response_part.update({'error' : 'Already signed up.'})
return HttpResponse(json.dumps(response_part), content_type="application/json")
else:
ps.add_element_permissions(user_key, elem_key, True)
response_part.update({'success' : True})
return HttpResponse(json.dumps(response_part), content_type="application/json")
示例3: test_element_get_element_key_by_ref
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import get_element_key_by_ref [as 別名]
def test_element_get_element_key_by_ref(self):
key = ps.add_element("someRefGekbr")
self.assertEqual(ps.get_element_key_by_ref("someRefGekbr"),key )