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


Python PowerType.by_id方法代码示例

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


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

示例1: delete_powertype

# 需要导入模块: from bkr.server.model import PowerType [as 别名]
# 或者: from bkr.server.model.PowerType import by_id [as 别名]
def delete_powertype(id):
    """
    Deletes a power type by the given id.

    :param id: The id of the power type to be deleted.
    :status 204: Power type successfully deleted.
    :status 400: Power type is referenced by systems.
    :status 404: Power type can not be found.
    """
    try:
        powertype = PowerType.by_id(id)
    except NoResultFound:
        raise NotFound404('Power type: %s does not exist' % id)

    systems_referenced = System.query.join(System.power).filter(
        Power.power_type == powertype).count()
    if systems_referenced:
        raise BadRequest400('Power type %s still referenced by %i systems' % (
            powertype.name, systems_referenced))

    session.delete(powertype)

    activity = Activity(identity.current.user, u'HTTP', u'Deleted', u'PowerType', powertype.name)
    session.add(activity)

    return '', 204
开发者ID:beaker-project,项目名称:beaker,代码行数:28,代码来源:power.py

示例2: save

# 需要导入模块: from bkr.server.model import PowerType [as 别名]
# 或者: from bkr.server.model.PowerType import by_id [as 别名]
 def save(self, **kw):
     if kw['id']:
         edit = PowerType.by_id(kw['id'])
         edit.name = kw['name']
     elif kw.get('name'):
         new = PowerType(name=kw['name'])
     else:
         flash(_(u"Invalid Power Type entry"))
         redirect(".")
     flash( _(u"OK") )
     redirect(".")
开发者ID:sibiaoluo,项目名称:beaker,代码行数:13,代码来源:power.py

示例3: edit

# 需要导入模块: from bkr.server.model import PowerType [as 别名]
# 或者: from bkr.server.model.PowerType import by_id [as 别名]
 def edit(self,**kw):
     values = []
     if kw.get('id'):
         powertype = PowerType.by_id(kw['id'])
         values = dict(
             id         = powertype.id,
             name       = powertype.name,
         )
     
     return dict(
         form = self.form,
         action = './save',
         options = {},
         value = values,
     )
开发者ID:sibiaoluo,项目名称:beaker,代码行数:17,代码来源:power.py

示例4: remove

# 需要导入模块: from bkr.server.model import PowerType [as 别名]
# 或者: from bkr.server.model.PowerType import by_id [as 别名]
 def remove(self, **kw):
     remove = PowerType.by_id(kw['id'])
     session.delete(remove)
     flash( _(u"%s Deleted") % remove.name )
     raise redirect(".")
开发者ID:sibiaoluo,项目名称:beaker,代码行数:7,代码来源:power.py


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