本文整理汇总了Python中models.List.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python List.get_by_id方法的具体用法?Python List.get_by_id怎么用?Python List.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.List
的用法示例。
在下文中一共展示了List.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import List [as 别名]
# 或者: from models.List import get_by_id [as 别名]
def post(self, version, service_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
service = Service.get_by_slug(service_slug)
if not service:
self.error(404, "Service %s does not exist" % service_slug)
return
name = self.request.get('name', default_value=None)
description = self.request.get('description', default_value=None)
list = self.request.get('list', default_value=None)
if description:
service.description = description
if name:
service.name = name
if list:
l = List.get_by_id(list)
if l is None:
self.error(400, "Can't find list with slug %s" % list)
return
service.list = l
if "" == list:
service.list = None
list = "removed"
if name or description or list:
invalidate_cache()
service.put()
self.json(service.rest(self.base_url(version)))
示例2: delete
# 需要导入模块: from models import List [as 别名]
# 或者: from models.List import get_by_id [as 别名]
def delete(self, list_id):
list = List.get_by_id(int(list_id))
list.key.delete()
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(json.dumps({'ok': True}))