本文整理汇总了Python中models.Person.key_for方法的典型用法代码示例。如果您正苦于以下问题:Python Person.key_for方法的具体用法?Python Person.key_for怎么用?Python Person.key_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Person
的用法示例。
在下文中一共展示了Person.key_for方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import key_for [as 别名]
def post(self):
self.fetch()
for person in self.people:
if self.request.get(u'person_%s_remove' % str(person.key())):
for auth in person.product_authorization.values():
auth.delete()
person.account_access.delete()
person.delete()
self.redirect_and_finish(u'%s/people/' % self.account_path, flash = u"%s removed." % (person.user.email()))
if self.request.get('new'):
txns = []
new_person_email = self.valid_string(u'new_person_email', required=False)
if new_person_email != None:
txns.append((create_person_txn, new_person_email))
person_key = Person.key_for(new_person_email)
admin = self.valid_bool(u'new_person_admin')
txns.append((update_person_account_access_txn, person_key, self.account.key(), admin))
for product in self.products:
level = self.valid_int(u'new_person_%s_level' % (product.key()))
txns.append((update_person_product_access_txn, person_key , product.key(), level))
if self.is_valid():
for txn in txns:
db.run_in_transaction(*txn)
self.redirect_and_finish(u'%s/people/' % self.account_path, flash = u"%s has been created." % new_person_email)
else:
self.new_person_email = new_person_email
self.render_screen_and_finish()
else:
txns = []
for person in self.people:
admin = self.valid_bool(u'person_%s_admin' % person.key())
txns.append((update_person_account_access_txn, person.key(), self.account.key(), admin))
for product in self.products:
level = self.valid_int(u'person_%s_%s_level' % (person.key(), product.key()))
txns.append((update_person_product_access_txn, person.key(), product.key(), level))
if self.is_valid():
for txn in txns:
db.run_in_transaction(*txn)
self.redirect_and_finish(u'%s/people/' % self.account_path, flash = u"Permission settings have been saved.")
else:
self.render_screen_and_finish()
示例2: create_person_txn
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import key_for [as 别名]
def create_person_txn(email):
key = Person.key_for(email)
p = db.get(key)
if not p:
p = Person(key_name=key.name(), user=users.User(email))
p.put()