本文整理汇总了Python中bkr.server.model.Key.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Key.by_id方法的具体用法?Python Key.by_id怎么用?Python Key.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bkr.server.model.Key
的用法示例。
在下文中一共展示了Key.by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit
# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_id [as 别名]
def edit(self, **kw):
values = []
if kw.get("id"):
key = Key.by_id(kw["id"])
values = dict(id=key.id, key_name=key.key_name, numeric=key.numeric)
return dict(form=self.form, action="./save", options={}, value=values)
示例2: save
# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_id [as 别名]
def save(self, **kw):
if kw['id']:
key = Key.by_id(kw['id'])
key.key_name = kw['key_name']
else:
key = Key(key_name=kw['key_name'])
session.add(key)
if 'numeric' in kw:
key.numeric = kw['numeric']
flash( _(u"OK") )
redirect(".")
示例3: save
# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_id [as 别名]
def save(self, **kw):
if kw["id"]:
key = Key.by_id(kw["id"])
key.key_name = kw["key_name"]
else:
key = Key(key_name=kw["key_name"])
session.add(key)
if "numeric" in kw:
key.numeric = kw["numeric"]
flash(_(u"OK"))
redirect(".")
示例4: save
# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_id [as 别名]
def save(self, **kw):
if kw["id"]:
key = Key.by_id(kw["id"])
key.key_name = kw["key_name"]
else:
if Key.query.filter_by(key_name=kw["key_name"]).first():
flash(u"Key Type exists: %s" % kw["key_name"])
redirect(".")
key = Key(key_name=kw["key_name"])
session.add(key)
key.numeric = kw["numeric"]
flash(_(u"OK"))
redirect(".")
示例5: edit
# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_id [as 别名]
def edit(self,**kw):
values = []
if kw.get('id'):
key = Key.by_id(kw['id'])
values = dict(
id = key.id,
key_name = key.key_name,
numeric = key.numeric
)
return dict(
form = self.form,
action = './save',
options = {},
value = values,
)
示例6: remove
# 需要导入模块: from bkr.server.model import Key [as 别名]
# 或者: from bkr.server.model.Key import by_id [as 别名]
def remove(self, **kw):
remove = Key.by_id(kw['id'])
session.delete(remove)
flash( _(u"%s Deleted") % remove.key_name )
raise redirect(".")