本文整理匯總了Python中API.APIPermissions.add_element方法的典型用法代碼示例。如果您正苦於以下問題:Python APIPermissions.add_element方法的具體用法?Python APIPermissions.add_element怎麽用?Python APIPermissions.add_element使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類API.APIPermissions
的用法示例。
在下文中一共展示了APIPermissions.add_element方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: signup_handler
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_element [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")
示例2: test_element_get_element_key_by_ref
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_element [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 )
示例3: test_element_get_element_by_key
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_element [as 別名]
def test_element_get_element_by_key(self):
key = ps.add_element("someRefGebk")
self.assertEqual(ps.get_element_by_key(key).element_ref,"someRefGebk" )
示例4: test_element_rename_element
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_element [as 別名]
def test_element_rename_element(self):
key = ps.add_element("someRefRe")
ps.rename_element("someRefRe","someNewRefRe")
self.assertEqual(ps.get_element_by_key(key).element_ref, "someNewRefRe")
示例5: test_element_remove_element_by_key
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_element [as 別名]
def test_element_remove_element_by_key(self):
key = ps.add_element("someRefRebk")
self.assertTrue(ps.remove_element_by_key(key))
示例6: test_element_remove_element_by_ref
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_element [as 別名]
def test_element_remove_element_by_ref(self):
ps.add_element("someRefRebr")
self.assertTrue(ps.remove_element_by_ref("someRefRebr"))
示例7: test_element_add_element
# 需要導入模塊: from API import APIPermissions [as 別名]
# 或者: from API.APIPermissions import add_element [as 別名]
def test_element_add_element(self):
ret = ps.add_element( "someRefae" )
self.assertTrue(isinstance(ret, ndb.Key))