def touch_dids(dids, session=None):
"""
Update the accessed_at timestamp of the given dids.
:param replicas: the list of dids.
:param session: The database session in use.
:returns: True, if successful, False otherwise.
"""
now = datetime.utcnow()
try:
for did in dids:
session.query(models.DataIdentifier).filter_by(scope=did['scope'], name=did['name'], did_type=did['type']).\
update({'accessed_at': did.get('accessed_at') or now}, synchronize_session=False)
except DatabaseError:
return False
return True
评论列表
文章目录