本文整理汇总了Python中models.Service.query方法的典型用法代码示例。如果您正苦于以下问题:Python Service.query方法的具体用法?Python Service.query怎么用?Python Service.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Service
的用法示例。
在下文中一共展示了Service.query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_services
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import query [as 别名]
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)
示例2: get
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import query [as 别名]
def get(self):
if not setup_occurred():
self.redirect("/admin/setup")
td = default_template_data()
td["services_selected"] = True
td["services"] = Service.query().order(Service.name).fetch(1000)
self.render(td, 'admin/services.html')
示例3: get
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import query [as 别名]
def get(self, version):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
query = Service.query().order(Service.name)
data = [s.rest(self.base_url(version)) for s in query]
data = {"services": data}
self.json(data)
示例4: delete
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import query [as 别名]
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)))
示例5: test_delete_entity_cascade
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import query [as 别名]
def test_delete_entity_cascade(self):
# TODO: test erroneous cascade delete of entities, that are referenced
# as a required property.
initial_dts_count = [
{'service': s,
'count': len(
s.backref_query('DocumentToService', 'service').fetch())}
for s in Service.query().fetch()
]
# == Testing cascade delete of references ==
test_mfc = MFC.by_property('name', u'МФЦ г. Нюрба')
testmfc_urlsafe = test_mfc.urlsafe()
self.testapp.delete('/admin/api/entities/' + testmfc_urlsafe)
# Only one MFC entity is left.
self.assertEqual(len(MFC.query().fetch()), 1)
# Only one MFC entity is now referenced by the sole kompleks in test
# data.
kompleks = Kompleks.by_property('name', u'Рождение ребенка')
self.assertEqual(len(kompleks.mfcs), 1)
# == Testing cascade delete of linked DocumentToService entities ==
test_doc = Document.by_property(
'name', u'Документ, удостоверяющий личность заявителя')
testdoc_urlsafe = test_doc.urlsafe()
self.testapp.delete('/admin/api/entities/' + testdoc_urlsafe)
# All DocumentToService entities linked to the deleted document are gone
# as well.
for item in initial_dts_count:
s = item['service']
self.assertEqual(
item['count'] - 1,
len(s.backref_query('DocumentToService', 'service').fetch()))