本文整理汇总了Python中models.Status.query方法的典型用法代码示例。如果您正苦于以下问题:Python Status.query方法的具体用法?Python Status.query怎么用?Python Status.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Status
的用法示例。
在下文中一共展示了Status.query方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import query [as 别名]
def get(self, version):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
query = Status.query().order(Status.name)
data = [s.rest(self.base_url(version)) for s in query]
self.json({"statuses": data})
示例2: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import query [as 别名]
def get(self, slug):
service = Service.get_by_slug(slug)
if not service:
self.not_found()
return
td = {
"services_selected": True,
"service": service,
"statuses": Status.query().fetch(100),
}
td.update(site.default_template_data())
self.render(td, 'admin/events_create.html')
示例3: post
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import query [as 别名]
def post(self, version, status_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
status = Status.get_by_slug(status_slug)
if not status:
self.error(404, "No status with the slug %s found" % status_slug)
return
name = self.request.get('name', default_value=None)
image_slug = self.request.get('image', default_value=None)
image = None
default = self.request.get('default', default_value=None)
description = self.request.get('description', default_value=None)
if image_slug is not None:
image = Image.get_by_slug(image_slug)
if image is None:
self.error(400, "An Image with the "
"slug %s doesn't exist" % image_slug)
return
status.image = image.path
if description is not None:
status.description = description
if default is not None and default in ["false", "true"]:
# Reset default status
if default == "true":
for stat in Status.query().filter(Status.default == True):
stat.default = False
stat.put()
status.default = default == "true"
if name is not None:
status.name = name
if description or name or image or default:
status.put()
invalidate_cache()
self.json(status.rest(self.base_url(version)))
示例4: data
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import query [as 别名]
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(),
}
示例5: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import query [as 别名]
def get(self, service_slug, year=None, month=None, day=None):
service = Service.get_by_slug(service_slug)
if not service:
self.not_found()
return
try:
if day:
start_date = datetime(int(year), int(month), int(day))
end_date = start_date + timedelta(days=1)
elif month:
start_date = datetime(int(year), int(month), 1)
days = calendar.monthrange(start_date.year,
start_date.month)[1]
end_date = start_date + timedelta(days=days)
elif year:
start_date = datetime(int(year), 1, 1)
end_date = start_date + timedelta(days=365)
else:
start_date = None
end_date = None
except ValueError:
self.not_found(404)
return
events = service.events
if start_date and end_date:
events.filter(Event.start >= start_date).filter(Event.start < end_date)
td = default_template_data()
td["statuses"] = Status.query().fetch(100)
td["service"] = service
td["events"] = events.order(-Event.start).fetch(500)
self.render(td, 'service.html')
示例6: run
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import query [as 别名]
def run(self):
logging.info("Update each status")
# For each status
for status in Status.query().fetch(100):
# Set the status to default
status.default = False
# Update the status url
status.image = "icons/fugue/" + status.image + ".png"
# Save the status
status.put()
# Get the up status and make it default
default_status = Status.get_by_slug("up")
if default_status is None:
logging.error("Could not find the up status")
return
default_status.default = True
default_status.put()
logging.info("Set up status as the default")