本文整理汇总了Python中models.Place.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Place.get_by_id方法的具体用法?Python Place.get_by_id怎么用?Python Place.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Place
的用法示例。
在下文中一共展示了Place.get_by_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: place_page
# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import get_by_id [as 别名]
def place_page(place_id=None):
if request.method == 'POST':
p = Place.get_by_id(place_id)
# for add subscriber form
if 'email' in request.form:
email = request.form.get('email', '')
if email not in [u.email for u in User.all()]:
u = User(
email=email,
suscribed_at=datetime.datetime.now())
u.put()
else:
u = User.gql("WHERE email = '{0}'".format(email)).get()
up = UserPlace.all().filter('user =', u).filter('place =', p).get()
if up:
return "This user already exists in subscribers!"
else:
if u.places_subscribed.count() >= 4:
return "This user has maximum subscribing"
up = UserPlace(
user=u,
place=p
)
up.put()
# for add update form
elif 'update_link' in request.form and 'update_info' in request.form:
update_link = request.form.get('update_link', '')
update_info = request.form.get('update_info', '')
u = Update(
place=p,
link=update_link,
info=update_info
)
u.put()
# for add link form
elif 'link_link' in request.form and 'link_description' in request.form:
link_link = request.form.get('link_link', '')
link_description = request.form.get('link_description', '')
l = PlaceLink(
place=p,
link=link_link,
description=link_description
)
l.put()
p = Place.get_by_id(place_id)
updates = [update for update in p.place_updates.order('-added_at')]
links = [link for link in p.placelink_set.order('-added_at')]
return render_template('place.html', place=p, updates=updates, links=links)