本文整理汇总了Python中models.Event.rest方法的典型用法代码示例。如果您正苦于以下问题:Python Event.rest方法的具体用法?Python Event.rest怎么用?Python Event.rest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Event
的用法示例。
在下文中一共展示了Event.rest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_event
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import rest [as 别名]
def test_create_event(self):
s = Service(slug=u"hey", name=u"you", description=u"lol")
s.put()
stat = Status(name=u"you", slug=u"leave", description=u"why",
image=u"cry")
stat.put()
e = Event(status=stat, service=s, message=u"¨¥¨œ∑´æ")
e.put()
data = e.rest("/api")
示例2: post
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import rest [as 别名]
def post(self, version, service_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
status_slug = self.request.get("status", default_value=None)
message = self.request.get("message", default_value=None)
informational = self.request.get("informational", default_value=None)
if not message:
self.error(400, "Event message is required")
return
service = Service.get_by_slug(service_slug)
if not service:
self.error(404, "Service %s not found" % service_slug)
return
if not status_slug:
event = service.current_event()
if event:
status = event.status
else:
status = Status.get_default()
else:
status = Status.get_by_slug(status_slug)
if not status:
self.error(404, "Status %s not found" % status_slug)
return
e = Event(status=status, service=service, message=message)
e.informational = informational and informational == "true"
e.put()
# Queue up a task that calls the Twitter API to make a tweet.
if self.request.get('tweet'):
logging.info('Attempting to post a tweet for the latest event via async GAE task queue.')
taskqueue.add(url='/admin/tweet', params={'service_name': service.name, 'status_name': status.name, 'message': message})
#TODO - insert Hipchat notification here
logging.info('*** Sending update to Hipchat room')
taskqueue.add(url='/admin/hipchat', params={'service_name': service.name, 'status_name': status.name, 'message': message})
invalidate_cache()
self.json(e.rest(self.base_url(version)))
示例3: post
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import rest [as 别名]
def post(self, version, service_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
status_slug = self.request.get("status", default_value=None)
message = self.request.get("message", default_value=None)
informational = self.request.get("informational", default_value=None)
if not message:
self.error(400, "Event message is required")
return
service = Service.get_by_slug(service_slug)
if not service:
self.error(404, "Service %s not found" % service_slug)
return
if not status_slug:
event = service.current_event()
if event:
status = event.status
else:
status = Status.get_default()
else:
status = Status.get_by_slug(status_slug)
if not status:
self.error(404, "Status %s not found" % status_slug)
return
e = Event(status=status, service=service, message=message)
e.informational = informational and informational == "true"
e.put()
invalidate_cache()
self.json(e.rest(self.base_url(version)))
示例4: post
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import rest [as 别名]
def post(self, version, service_slug):
logging.debug("EventsListHandler#post")
if (self.valid_version(version)):
status_slug = self.request.get("status", default_value=None)
message = self.request.get("message", default_value=None)
informational = self.request.get("informational", default_value=None)
if message:
service = Service.get_by_slug(service_slug)
if service:
if not status_slug:
event = service.current_event()
if event:
status = event.status
else:
status = Status.default()
else:
status = Status.get_by_slug(status_slug)
if status:
e = Event(status=status, service=service,
message=message)
e.informational = informational and informational == "true"
e.put()
self.json(e.rest(self.base_url(version)))
else:
self.error(404, "Status %s not found" % status_slug)
else:
self.error(404, "Service %s not found" % service_slug)
else:
self.error(400, "Event message is required")
else:
self.error(404, "API Version %s not supported" % version)
示例5: post
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import rest [as 别名]
def post(self, version, service_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
status_slug = self.request.get("status", default_value=None)
message = self.request.get("message", default_value=None)
informational = self.request.get("informational", default_value=None)
if not message:
self.error(400, "Event message is required")
return
service = Service.get_by_slug(service_slug)
if not service:
self.error(404, "Service %s not found" % service_slug)
return
last_event = service.current_event()
if last_event:
old_status = last_event.status
if not status_slug:
if last_event:
status = old_status
else:
status = Status.get_default()
else:
status = Status.get_by_slug(status_slug)
if not status:
self.error(404, "Status %s not found" % status_slug)
return
e = Event(status=status, service=service, message=message)
e.informational = informational and informational == "true"
e.put()
# Queue up a task that calls the Twitter API to make a tweet.
if self.request.get('tweet'):
logging.info('Attempting to post a tweet for the latest event via async GAE task queue.')
taskqueue.add(url='/admin/tweet', params={'service_name': service.name, 'status_name': status.name, 'message': message})
# Queue up tasks for notifing subscribers via XMPP
if service.subscriptions:
for subscription in service.subscriptions.filter("type =","xmpp"):
mobile = Mobile.all().filter('subscription = ', subscription).get()
if mobile:
mobile_number = mobile.number
else:
mobile_number = False
params={'address': subscription.address, 'service':
service.key(), 'oldstatus': old_status.key(), 'number': mobile_number}
logging.info("Adding deferred task: %s %s" % (
subscription.type, params))
taskqueue.add(url='/notify/' + subscription.type, params=params)
else:
logging.info("No subscriptions for %s" % service.name)
invalidate_cache()
self.json(e.rest(self.base_url(version)))