wopiserver.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:wopiserver 作者: cernbox 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号