当前位置: 首页>>代码示例>>Python>>正文


Python Person.key_for方法代码示例

本文整理汇总了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()
开发者ID:B-Rich,项目名称:crashkit,代码行数:49,代码来源:accountedit.py

示例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()
开发者ID:B-Rich,项目名称:crashkit,代码行数:8,代码来源:accountedit.py


注:本文中的models.Person.key_for方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。