本文整理汇总了Python中girder.models.model_base.Model.update方法的典型用法代码示例。如果您正苦于以下问题:Python Model.update方法的具体用法?Python Model.update怎么用?Python Model.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类girder.models.model_base.Model
的用法示例。
在下文中一共展示了Model.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate
# 需要导入模块: from girder.models.model_base import Model [as 别名]
# 或者: from girder.models.model_base.Model import update [as 别名]
def validate(self, doc):
if doc.get('score') is not None and doc.get('overallScore') is None:
scoring.computeAverageScores(doc['score'])
phase = self.model('phase', 'challenge').load(
doc['phaseId'], force=True)
doc['overallScore'] = scoring.computeOverallScore(doc, phase)
doc['latest'] = True
Model.update(self, query={
'phaseId': doc['phaseId'],
'creatorId': doc['creatorId'],
'latest': True
}, update={
'$set': {'latest': False}
})
return doc
示例2: validate
# 需要导入模块: from girder.models.model_base import Model [as 别名]
# 或者: from girder.models.model_base.Model import update [as 别名]
def validate(self, doc):
if doc.get('created'):
doc['created'] = validateDate(doc.get('created'), 'created')
if doc.get('approach') in {'default', ''}:
del doc['approach']
if doc.get('score') is not None and doc.get('overallScore') is None:
scoring.computeAverageScores(doc['score'])
phase = Phase().load(
doc['phaseId'], force=True)
doc['overallScore'] = scoring.computeOverallScore(doc, phase)
doc['latest'] = True
Model.update(self, query={
'phaseId': doc['phaseId'],
'creatorId': doc['creatorId'],
'approach': doc.get('approach'),
'latest': True
}, update={
'$set': {'latest': False}
})
return doc