本文整理汇总了Python中models.List类的典型用法代码示例。如果您正苦于以下问题:Python List类的具体用法?Python List怎么用?Python List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了List类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_tables
def create_tables():
Number.create_table(True)
SMS.create_table(True)
Seller.create_table(True)
Market.create_table(True)
List.create_table(True)
ListRelationship.create_table(True)
Outbox.create_table(True)
示例2: data
def data(self):
services = []
default_status = Status.get_default()
lists = []
for list in self.lists:
l = List.get_by_slug(list)
if l is not None:
lists.append(l)
for service in Service.all().filter("list IN", lists).order("name").fetch(100):
event = service.current_event()
if event is not None:
status = event.status
else:
status = default_status
if len(self.statuses) and not status.slug in self.statuses:
continue
today = date.today() + timedelta(days=1)
current, = service.history(1, default_status, start=today)
has_issues = current["information"] and status.key() == default_status.key()
service_dict = {
"slug": service.slug,
"name": service.name,
"url": service.url(),
"status": status,
"has_issues": has_issues,
"history": service.history(5, default_status),
}
services.append(service_dict)
return {"days": get_past_days(5), "statuses": Status.all().fetch(100), "services": services}
示例3: post
def post(self, version):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
name = self.request.get('name', default_value=None)
description = self.request.get('description', default_value=None)
if not name or not description:
self.error(400, "Bad Data: Name: %s, Description: %s" \
% (name, description))
return
slug = slugify.slugify(name)
existing_s = List.get_by_slug(slug)
if existing_s:
self.error(404, "A list with this name already exists")
return
l = List(name=name, slug=slug, description=description)
l.put()
invalidate_cache()
self.response.set_status(201)
self.json(l.rest(self.base_url(version)))
示例4: _get_all
def _get_all(self):
_lists = objList.get_all()
if not _lists:
return make_response(dumps([]))
return make_response(dumps(_lists))
示例5: post
def post(self):
args = parser.parse_args()
if not args.name:
abort(500)
_l = objList.add(args.name)
return _l
示例6: test_post_update_desc
def test_post_update_desc(self):
response = self.post("/admin/api/v1/service-lists/foo",
data={"description": "hello"})
self.assertEquals(response.headers["Content-Type"], "application/json")
self.assertEquals(response.status_code, 200)
service = List.get(self.service_list.key())
self.assertEquals(service.description, "hello")
示例7: get
def get(self):
results = []
q = List.query()
for list in q.iter():
results.append(list.to_dict())
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(json.dumps(results));
示例8: test_post_update
def test_post_update(self):
response = self.post("/admin/api/v1/service-lists/foo",
data={"name": "bar"})
self.assertEquals(response.headers["Content-Type"], "application/json")
self.assertEquals(response.status_code, 200)
service = List.get(self.service_list.key())
self.assertEquals(service.name, "bar")
示例9: get
def get(self, version):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
query = List.all().order('name')
data = [s.rest(self.base_url(version)) for s in query]
data = {"lists": data}
self.json(data)
示例10: get
def get(self):
lists = List.query().fetch(20)
newList = []
for item in lists:
newList.append({"name": item.name,
"listKey": item.key.urlsafe()})
self.response.write(json.dumps(newList))
示例11: get
def get(self):
td = {
"services_selected": True,
"url": "/admin/api/v1/services",
"action": "create",
"service_lists": List.all().fetch(100),
}
td.update(site.default_template_data())
self.render(td, 'admin/services_create.html')
示例12: put
def put(self, list_id=None):
if not list_id:
abort(500)
args = parser.parse_args()
if not args.name:
abort(500)
_l = objList.update(list_id, args.name)
return _l
示例13: get
def get(self, list_slug):
self.list = List.get_by_slug(list_slug)
if self.list is None:
self.not_found()
return
td = default_template_data()
td.update(self.retrieve("list"+list_slug))
#td.update(self.data())
self.render(td, 'index.html')
示例14: data
def data(self):
default_status = Status.get_default()
lists = []
for list in self.lists:
l = List.get_by_slug(list)
if l is not None:
lists.append(l)
@ndb.toplevel
def get_services():
services = []
for service in Service.query().filter(Service.list in lists).order(Service.name).fetch(100):
event = yield service.current_event_async()
if event is not None:
status = event.status
else:
status = default_status
if len(self.statuses) and not status.slug in self.statuses: continue
today = datetime.today() + timedelta(days=1)
current = yield service.history_async(1, default_status, start=today)
current = current[0]
has_issues = current["information"] and status.key == default_status.key
history = yield service.history_async(5, default_status)
service_dict = {
"slug": service.slug,
"name": service.name,
"url": service.url(),
"status": status,
"has_issues": has_issues,
"history": history,
}
services.append(service_dict)
raise ndb.Return(services)
return {
"days": get_past_days(5),
"statuses": Status.query().fetch(100),
"services": get_services(),
}
示例15: delete
def delete(self, version, list_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
list = List.get_by_slug(list_slug)
if not list:
self.error(404, "List %s not found" % list_slug)
return
query = Service.query().filter(Service.list == list)
for s in query:
s.list = None
s.put()
invalidate_cache()
list.delete()
self.json(list.rest(self.base_url(version)))