本文整理汇总了Python中model.user.User.key方法的典型用法代码示例。如果您正苦于以下问题:Python User.key方法的具体用法?Python User.key怎么用?Python User.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_or_existing_ga
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import key [as 别名]
def new_or_existing_ga(user, alias_suggestion=None):
#id = unicode(type(user).__name__.lower() +':'+ user.user_id())
id = unicode('ah:'+ user.user_id())
entity = User.get_by_key_name(id)
if not entity:
entity = User(key_name=id, email=user.email())
entity.put()
logger.debug("Created user %s (%s)", entity.email, entity.key().name())
#if alias_suggestion and not find_alias(alias_suggestion):
# alias = new_alias(entity, alias_suggestion)
#else:
# alias = new_alias_for(entity)
#assert alias, "FIXME: Cannot create Alias for %s" % user.email()
#alias.put()
#logger.debug("Created alias %s for user (%s).", alias.handle, entity.key().name())
elif entity.email != user.email():
entity.email = user.email()
entity.put()
#alias = new_alias_for(entity)
#if alias:
# logger.debug("Updating user %s for alias %s. ", user.email(), newalias)
# alias.put()
#else:
# logger.info("New alias not available for user %s. ", user.email())
return entity
示例2: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import key [as 别名]
def post(self):
if not self.validate(self.request):
self.render_form()
else:
user = User(name=self.username, password_hash=Hash.password(self.username, self.password), email=(self.email if self.email else None ))
user.put()
self.set_cookie('userid', user.key())
self.redirect('/blog/home')