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


Python Images.first方法代码示例

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


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

示例1: delete

# 需要导入模块: from models import Images [as 别名]
# 或者: from models.Images import first [as 别名]
    def delete(self, id):
        image = Images.first(id=id)
        msg = "The image could not be deleted."
        if image and Images.delete(image):
            msg = "Image deleted"
        cherrypy.session['flash'] = msg

        raise cherrypy.HTTPRedirect('/images')
开发者ID:masom,项目名称:Puck,代码行数:10,代码来源:images.py

示例2: edit

# 需要导入模块: from models import Images [as 别名]
# 或者: from models.Images import first [as 别名]
    def edit(self, id, **post):
        image = Images.first(id=id)

        if not image:
            cherrypy.session['flash'] = "404 Image Not Found"
            raise cherrypy.HTTPRedirect('/images')

        if post:
            fields = ['name', 'backend_id', 'description']
            data = self._get_data('image', fields, post)
            if image.update(data, fields):
                cherrypy.session['flash'] = "Image successfully updated."
                raise cherrypy.HTTPRedirect('/images')

            cherrypy.session['flash'] = 'Invalid data'

        backend_images = Images.get_backend_images()
        env=dict(image = image, backend_images=backend_images)
        return self.render("/images/edit.html", crumbs=self.crumbs, **env)
开发者ID:masom,项目名称:Puck,代码行数:21,代码来源:images.py

示例3: start

# 需要导入模块: from models import Images [as 别名]
# 或者: from models.Images import first [as 别名]
    def start(self, **post):
        if post:
            self._validate_start_post_data(post)
            creds = cherrypy.session.get('credentials')

            image = Images.first(id=post['image.id'])
            instance_type = self._get_instance_type(post)

            self._validate_start_args(image, instance_type)

            vm = VirtualMachines.new(status="new")

            if VirtualMachines.add(vm):
                if not vm.start_instance(image, instance_type, creds):
                    cherrypy.session['flash'] = 'The virtual machine could not be started.'
                    raise cherrypy.HTTPRedirect("/virtual_machines")
        else:
            cherrypy.session['flash'] = 'Missing image id.'

        raise cherrypy.HTTPRedirect("/virtual_machines")
开发者ID:masom,项目名称:Puck,代码行数:22,代码来源:virtual_machines.py


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