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


Python Status.rest方法代码示例

本文整理汇总了Python中models.Status.rest方法的典型用法代码示例。如果您正苦于以下问题:Python Status.rest方法的具体用法?Python Status.rest怎么用?Python Status.rest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Status的用法示例。


在下文中一共展示了Status.rest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import rest [as 别名]
    def post(self, version):
        
        if (self.valid_version(version)):
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            image = self.request.get('image', default_value=None)
            level = self.request.get('level', default_value=None)
            severity = Level.get_severity(level)

            if name and description and severity and image:
                slug = slugify.slugify(name)
                status = Status.get_by_slug(slug)

                # Update existing resource
                if status:
                    status.description = description
                    status.severity = severity
                    status.image = image
                    status.name = name
                    status.put()
                    self.json(status.rest(self.base_url(version)))
                # Create new service
                else:
                    status = Status(name=name, slug=slug, description=description, 
                        severity=severity, image=image)
                    status.put()
                    self.json(status.rest(self.base_url(version)))
            else:
                self.error(400, "Bad Data")
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:samn,项目名称:stashboard,代码行数:33,代码来源:api.py

示例2: test_status_warning

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import rest [as 别名]
    def test_status_warning(self):
        s = Status(name=u"Hey", slug=u"hey", description=u"runaway",
                   image=u"helloworld.png", severity=30)
        s.put()

        data = s.rest("/api")
        self.assertEquals(data["level"], "WARNING")
开发者ID:2do,项目名称:stashboard,代码行数:9,代码来源:test_status.py

示例3: test_status_normal

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import rest [as 别名]
    def test_status_normal(self):
        s = Status(name=u"Hey", slug=u"hey", description=u"runaway",
                   image=u"helloworld.png", severity=10)
        s.put()

        data = s.rest("/api")
        self.assertEquals(data["level"], "NORMAL")
开发者ID:2do,项目名称:stashboard,代码行数:9,代码来源:test_status.py

示例4: post

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import rest [as 别名]
    def post(self, version):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        name = self.request.get('name', default_value=None)
        description = self.request.get('description', default_value=None)
        image_slug = self.request.get('image', default_value=None)
        default = self.request.get('default', default_value="false")

        if default not in ["true", "false"]:
            self.error(400, "Default must be true or false")
            return

        if not name or not description or not image_slug:
            self.error(400, "Bad Data")
            return

        slug = slugify.slugify(name)
        status = Status.get_by_slug(slug)
        image = Image.get_by_slug(image_slug)

        if status is not None:
            self.error(400, "A Status with the slug %s already exists" % slug)
            return

        if image is None:
            msg = "An Image with the slug %s doesn't exist" % image_slug
            self.error(400, msg)
            return

        # Reset default status
        if default == "true":
            for stat in Status.all().filter("default", True):
                stat.default = False
                stat.put()

        default = default == "true"
        status = Status(name=name, slug=slug, description=description,
                        image=image.path, default=default)
        status.put()
        invalidate_cache()

        self.response.set_status(201)
        self.json(status.rest(self.base_url(version)))
开发者ID:Tradeshift,项目名称:stashboard,代码行数:47,代码来源:api.py

示例5: test_create_image

# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import rest [as 别名]
 def test_create_image(self):
     s = Status(name=u"∆", slug=u"∑´", description=u"œˆø", image=u"©˙")
     s.put()
     data = s.rest("/api")
开发者ID:2do,项目名称:stashboard,代码行数:6,代码来源:test_unicode.py


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