本文整理汇总了Python中action.Action.newFromDict方法的典型用法代码示例。如果您正苦于以下问题:Python Action.newFromDict方法的具体用法?Python Action.newFromDict怎么用?Python Action.newFromDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类action.Action
的用法示例。
在下文中一共展示了Action.newFromDict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: putAction
# 需要导入模块: from action import Action [as 别名]
# 或者: from action.Action import newFromDict [as 别名]
def putAction(self, user, actionDict):
assert isinstance(user, User)
if 'userID' not in actionDict or 'no' not in actionDict or 'act' not in actionDict or 'data' not in actionDict or 'comment' not in actionDict or 'time' not in actionDict or 'parent' not in actionDict or 'root' not in actionDict or 'sign' not in actionDict:
raise InvalidActionDictionary()
if actionDict['parent'] is not None and actionDict['parent'] not in self.actions:
raise NoParent()
action = Action.newFromDict(self.getID(), user, **actionDict)
if action.ID() in self.actions:
raise ActionExists()
self.actions[action.ID()] = action
if self.versions[user.ID()] < actionDict['no']:
self.versions[user.ID()] = actionDict['no']
if action.act == Action.Insert:
self.latests[action.ID()] = [action]
else:
latests = self.latests[action.root]
parent = self.get(action.parent)
for i in range(len(latests)):
if latests[i] == parent:
latests.pop(i)
latests.insert(0, action)
latests.sort(key=lambda x: x.time, reverse=True)
self._save()
return action.ID()