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


Python Service.slugify方法代码示例

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


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

示例1: post

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

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import slugify [as 别名]
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

from google.appengine.ext import db
from models import Status, Service, Event, Region
from datetime import datetime, timedelta, date

na = Region(name="North America")
na.put()

emea = Region(name="EMEA")
emea.put()

foo = Service(name="Service Foo", slug="service-foo", region=na,
              description="Scalable and reliable foo service across the globe")
foo.slug = Service.slugify(foo.name, foo.region.name)
foo.put()

bar = Service(name="Service Bar", slug="service-bar", region=emea,
             description="Scalable and reliable foo service")
bar.slug = Service.slugify(bar.name, bar.region.name)
bar.put()

delete = Service(name="Delete Me", slug="delete", region=na,
                description="Delete Me Please")
delete.slug = Service.slugify(delete.name, delete.region.name)
delete.put()

bar = Service.get_by_slug("emea-service-bar")
cat = Status.get_by_slug("down")        
开发者ID:samn,项目名称:stashboard,代码行数:32,代码来源:install_data.py


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