def migrate_uuid(node, wname):
 db = share_db()
 old_sharejs_uuid = get_sharejs_uuid(node, wname)
 broadcast_to_sharejs('lock', old_sharejs_uuid)
 generate_private_uuid(node, wname)
 new_sharejs_uuid = get_sharejs_uuid(node, wname)
 doc_item = db['docs'].find_one({'_id': old_sharejs_uuid})
 if doc_item:
  doc_item['_id'] = new_sharejs_uuid
  db['docs'].insert(doc_item)
  db['docs'].remove({'_id': old_sharejs_uuid})
 ops_items = [item for item in db['docs_ops'].find({'name': old_sharejs_uuid})]
 if ops_items:
  for item in ops_items:
   item['_id'] = item['_id'].replace(old_sharejs_uuid, new_sharejs_uuid)
   item['name'] = new_sharejs_uuid
  db['docs_ops'].insert(ops_items)
  db['docs_ops'].remove({'name': old_sharejs_uuid})
 write_contributors = [user._id for user in node.contributors if node.has_permission(user, 'write')]
 broadcast_to_sharejs('unlock', old_sharejs_uuid, data=write_contributors)

def migrate_uuid ( node , wname ) : db = share_db ( ) old_sharejs_uuid = get_sharejs_uuid ( node , wname ) broadcast_to_sharejs ( 'lock' , old_sharejs_uuid ) generate_private_uuid ( node , wname ) new_sharejs_uuid = get_sharejs_uuid ( node , wname ) doc_item = db [ 'docs' ] . find_one ( { '_id' : old_sharejs_uuid } ) if doc_item : doc_item [ '_id' ] = new_sharejs_uuid db [ 'docs' ] . insert ( doc_item ) db [ 'docs' ] . remove ( { '_id' : old_sharejs_uuid } ) ops_items = [ item for item in db [ 'docs_ops' ] . find ( { 'name' : old_sharejs_uuid } ) ] if ops_items : for item in ops_items : item [ '_id' ] = item [ '_id' ] . replace ( old_sharejs_uuid , new_sharejs_uuid ) item [ 'name' ] = new_sharejs_uuid db [ 'docs_ops' ] . insert ( ops_items ) db [ 'docs_ops' ] . remove ( { 'name' : old_sharejs_uuid } ) write_contributors = [ user . _id for user in node . contributors if node . has_permission ( user , 'write' ) ] broadcast_to_sharejs ( 'unlock' , old_sharejs_uuid , data = write_contributors )
migrates uuid to new namespace .