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


Python Service.rest方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import rest [as 别名]
    def post(self, version):
        logging.debug("ServicesListHandler#post")

        if (self.valid_version(version)):
            
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            region = self.request.get('region', default_value=None)
            
            if name and description and region:
                slug = Service.slugify(name, region)
                existing_s = Service.get_by_slug(slug)

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

示例2: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service 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)

        if not name or not description:
            self.error(400, "Bad Data: Name: %s, Description: %s" \
                           % (name, description))
            return

        slug = slugify.slugify(name)
        existing_s = Service.get_by_slug(slug)

        if existing_s:
            self.error(404, "A sevice with this name already exists")
            return

        s = Service(name=name, slug=slug, description=description)
        s.put()

        invalidate_cache()

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

示例3: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import rest [as 别名]
    def post(self, version):
        logging.debug("ServicesListHandler#post")

        if (self.valid_version(version)):
            
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            serviceurl = self.request.get('serviceurl', default_value=None)
            pattern = self.request.get('pattern', default_value=None)
            freq = self.request.get('freq', default_value=None)
            
            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if existing_s:
                    existing_s.description = description
                    existing_s.serviceurl = serviceurl
                    existing_s.pattern = pattern
                    existing_s.freq = freq
                    existing_s.put()
                    self.json(existing_s.rest(self.base_url(version)))
                # Create new service
                else:
                    s = Service(name=name, slug=slug, description=description, serviceurl=serviceurl)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s" % (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:johnclarkemills,项目名称:stashboard,代码行数:34,代码来源:api.py

示例4: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service 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)

            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if not existing_s:
                    s = Service(name=name, slug=slug, description=description)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
                else:
                    self.error(404, "A sevice with this name already exists")
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s" % (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:kyleconroy,项目名称:stashboard,代码行数:23,代码来源:api.py

示例5: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service 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)
        slist = self.request.get('list', default_value=None)
        l = None

        if slist:
            l = List.all().filter("slug =", slist).get()

        if not name:
            self.error(400, "Bad name: %s" % name)
            return

        if not description:
            self.error(400, "Bad description: %s" % description)
            return

        if slist and not l:
            self.error(400, "Bad list slug: %s" % slist)
            return

        slug = slugify.slugify(name)
        existing_s = Service.get_by_slug(slug)

        if existing_s:
            self.error(404, "A sevice with this name already exists")
            return

        s = Service(name=name, slug=slug, description=description, list=l)
        s.put()

        invalidate_cache()

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

示例6: test_create_service

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import rest [as 别名]
 def test_create_service(self):
     s = Service(slug=u"Ð", name=u"µ", description=u"À")
     s.put()
     data = s.rest("/api")
开发者ID:2do,项目名称:stashboard,代码行数:6,代码来源:test_unicode.py


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