当前位置: 首页>>代码示例>>Python>>正文


Python Event.rest方法代码示例

本文整理汇总了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")
开发者ID:2do,项目名称:stashboard,代码行数:14,代码来源:test_unicode.py

示例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)))
开发者ID:Homefinder,项目名称:stashboard,代码行数:49,代码来源:api.py

示例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)))
开发者ID:Tradeshift,项目名称:stashboard,代码行数:40,代码来源:api.py

示例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)
开发者ID:samn,项目名称:stashboard,代码行数:39,代码来源:api.py

示例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)))
开发者ID:feczo,项目名称:splashmon,代码行数:63,代码来源:api.py


注:本文中的models.Event.rest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。