本文整理汇总了Python中models.Service.get方法的典型用法代码示例。如果您正苦于以下问题:Python Service.get方法的具体用法?Python Service.get怎么用?Python Service.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Service
的用法示例。
在下文中一共展示了Service.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def post(self):
"""Notify subscribers that a service changed status."""
address = self.request.get('address')
service = Service.get(self.request.get('service'))
oldstatus = Status.get(self.request.get('oldstatus'))
number = self.request.get('number')
logging.info("Service: %s" % service)
logging.info("Service name: %s" % service.name)
msg = "%s changed state from %s to %s (%s)" % (
service.name, oldstatus.name,
service.current_event().status.name,
service.current_event().message)
user = Subscription.get_by_email(address)
if user.status == "available" or not number:
status_code = xmpp.send_message(address, msg)
chat_message_sent = (status_code == xmpp.NO_ERROR)
logging.info("Notified: %s\nmessage: %s code: %d" % (address, msg, status_code))
elif user.status == "unavailable" and number:
sms = smsgw(to = number, msg = msg)
sms.send()
logging.info("Offline SMS: %s\nmessage: %s" % (number, msg))
示例2: test_post_update
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def test_post_update(self):
response = self.post("/admin/api/v1/services/foo",
data={"name": "bar"})
self.assertEquals(response.headers["Content-Type"], "application/json")
self.assertEquals(response.status_code, 200)
service = Service.get(self.service.key())
self.assertEquals(service.name, "bar")
示例3: test_post_update_desc
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def test_post_update_desc(self):
response = self.post("/admin/api/v1/services/foo",
data={"description": "hello"})
self.assertEquals(response.headers["Content-Type"], "application/json")
self.assertEquals(response.status_code, 200)
service = Service.get(self.service.key())
self.assertEquals(service.description, "hello")
示例4: test_post_update_list
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def test_post_update_list(self):
response = self.post("/admin/api/v1/services/foo",
data={"list": "foo"})
print response.content
self.assertEquals(response.headers["Content-Type"], "application/json")
self.assertEquals(response.status_code, 200)
service = Service.get(self.service.key())
self.assertEquals(service.list.name, "Foo")
示例5: services_edit
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def services_edit(request):
id = int(request.GET.get('id'))
service = Service.get(db.Key.from_path('Service', id))
if request.method != 'POST':
form = ServiceForm(instance=service)
return respond(request, 'service_edit.html', {'form': form, 'id': id })
form = ServiceForm(request.POST,instance=service)
if form.is_valid():
entity = form.save()
entity.put()
return HttpResponseRedirect(reverse(services))
else:
return respond(request, 'service_edit.html', {'form': form })
示例6: get_service_or_404
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def get_service_or_404(host, port):
try:
service = Service.get(host, port)
except ServiceDoesNotExist:
restful.abort(404, message="Service {}:{} doesn't exist".format(host, port))
return service
示例7: services_delete
# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import get [as 别名]
def services_delete(request):
id = int(request.GET.get('id'))
service = Service.get(db.Key.from_path('Service', id))
service.active = False
service.put()
return HttpResponseRedirect(reverse(services))