def _resource_persist_update_attributes(self, scannable_id, local_record_id, attrs):
# Must be run in a transaction to avoid leaving invalid things in the DB on failure.
assert transaction.is_managed()
session = self._sessions[scannable_id]
global_record_id = session.local_id_to_global_id[local_record_id]
record = StorageResourceRecord.objects.get(pk = global_record_id)
''' Sometimes we are given reference to a BaseStorageResource and so we need to store the id
not the type. This code does the translation '''
cleaned_id_attrs = {}
for key, val in attrs.items():
if isinstance(val, BaseStorageResource):
cleaned_id_attrs[key] = session.local_id_to_global_id[val._handle]
else:
cleaned_id_attrs[key] = val
record.update_attributes(cleaned_id_attrs)
resource_manager.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录