本文整理汇总了Python中models.Activity.get_by_key_encoded方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.get_by_key_encoded方法的具体用法?Python Activity.get_by_key_encoded怎么用?Python Activity.get_by_key_encoded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.get_by_key_encoded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_key_encoded [as 别名]
def post(self):
if not self.form.validate():
self.set_message('error', 'Invalid activity info. Please fix errors and try again.',
flash=True, life=10)
return self.get()
activity_id = self.form.activity_id.data
if (activity_id != None and len(activity_id) > 0):
activity = Activity.get_by_key_encoded(activity_id)
# Check ownership
if (activity.owner != self.auth_current_user.username):
self.set_message('error', 'Post your own trip and edit it as much as you like!',
life=10, flash=True)
return redirect('/')
else:
activity
# TODO copy form data to activity
else:
# New Activity
activity = Activity.create(author=self.auth_current_user, **self.form.data)
self.set_message('success', 'Activity saved. Let\'s do it!', flash=True, life=10)
return redirect('/activity?activity=%s' % activity.key())
示例2: activity
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import get_by_key_encoded [as 别名]
def activity(self):
if self.request.args.has_key('activity'):
return Activity.get_by_key_encoded(self.request.args.get('activity'))
else:
return None