def rewrite_meta(metaPath, meta):
    donePath = metaPath.replace('_META', '_DONE')
    mdonPath = metaPath.replace('_META', '_MDON')
    dataPath = metaPath.replace('_META', '_DATA')
    auxiPath = metaPath.replace('_META', '_AUXI')
    paths = (dataPath, metaPath, auxiPath, donePath, mdonPath)
    ryw.db_print3('rewrite_meta: ' + repr(paths), 63)
    ryw.db_print3('rewrite_meta: ' + repr(meta), 62)
    ryw_meta.rewrite_meta(None, None, None, meta, paths)
def do_update_metadata(objroot, objID, version, meta, searchFile=None):
    """this is also called by merging incoming data in
    ProcessDiscs.deal_with_stub().  only there, we're going to worry
    about the optional incoming SearchFile argument. there,
    we're trying to re-use the searchFile argument without
    re-opening it over and over again."""

    if not searchFile:
        ryw.db_print('do_update_metadata: null searchFile', 11)
    else:
        ryw.db_print('do_update_metadata: reusing searchFile', 11)
    
    if not ryw_meta.rewrite_meta(objroot, objID, version, meta):
        ryw.give_bad_news('EditObject: rewrite_meta failed.', logging.error)
        return (False, None)

    if not searchFile:
        searchFile = ryw_meta.open_search_file(RepositoryRoot,
                                               grabWriteLock = True)
    if not searchFile:
        ryw.give_bad_news('EditObject: failed to open search file.',
                          logging.critical)
        return (False, None)
        
    searchFile.modify(meta)
    return (True, searchFile)