本文整理汇总了Python中models.Profile.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.get_by_key_name方法的具体用法?Python Profile.get_by_key_name怎么用?Python Profile.get_by_key_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.get_by_key_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_by_key_name [as 别名]
def post(self):
federated_identity = self.get_argument("openid_identifier")
logging.info(federated_identity)
profile = Profile.get_by_key_name(federated_identity)
if profile:
dest_url = "/blog"
else:
dest_url = "/register"
login_url = users.create_login_url(dest_url=dest_url, federated_identity=federated_identity)
self.redirect(login_url)
示例2: get
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_by_key_name [as 别名]
def get(self):
user = users.get_current_user()
if user:
identity = user.federated_identity()
if identity and Profile.get_by_key_name(identity):
self.redirect("/blog")
else:
self.redirect("/register")
else:
self.render("index.html", video_url=configuration.INTRO_VIDEO_URL, login_url="/login")
示例3: GET
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_by_key_name [as 别名]
def GET(self):
p = Profile.get_by_key_name(self.key) or {}
s = SatScore.get_by_key_name(self.key) or {}
sat2s = SatSubjectScore.all().filter('uid =', self.key)
return super(self.__class__, self).GET({
'profile' : p,
'sat' : s,
'sat2s' : sat2s,
'groups' : SatSubjectScore._subject_categories,
'subjects' : SatSubjectScore._subjects
})
示例4: process_profile
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_by_key_name [as 别名]
def process_profile(self):
params = web.input()
keys = ['firstname', 'lastname', 'age', 'school']
attrs = { k : params[k] for k in keys }
attrs['age'] = int(attrs['age'])
attrs['uid'] = self.key
attrs['email'] = auth.user().email();
p = Profile.get_by_key_name(self.key)
if not p:
p = Profile(key_name=self.key, **attrs)
else:
for k, v in attrs.iteritems():
setattr(p, k, v)
try:
p.put()
except TransactionFailedError:
# Ideally handle the error
pass