def wopiGetLock(fileid, reqheaders_unused, acctok):
'''Implements the GetLock WOPI call'''
resp = flask.Response()
# throws exception if no lock
resp.headers['X-WOPI-Lock'] = _retrieveWopiLock(fileid, 'GETLOCK', '', acctok)
resp.status_code = httplib.OK
# for statistical purposes, check whether a lock exists and update internal bookkeeping
if resp.headers['X-WOPI-Lock']:
try:
# the file was already opened for write, check whether this is a new user
if not acctok['username'] in Wopi.openfiles[acctok['filename']][1]:
# yes it's a new user
Wopi.openfiles[acctok['filename']][1].add(acctok['username'])
if len(Wopi.openfiles[acctok['filename']][1]) > 1:
# for later monitoring, explicitly log that this file is being edited by at least two users
Wopi.log.info('msg="Collaborative editing detected" filename="%s" token="%s" users="%s"' % \
(acctok['filename'], flask.request.args['access_token'][-20:], list(Wopi.openfiles[acctok['filename']][1])))
except KeyError:
# existing lock but missing Wopi.openfiles[acctok['filename']] ?
Wopi.openfiles[acctok['filename']] = (time.asctime(), sets.Set([acctok['username']]))
return resp
评论列表
文章目录