コード例 #1
0
def do_show(objID, version):

    success,meta,objroot = ryw_meta.get_meta2(RepositoryRoot, objID, version)
    if not success:
        return False

    ryw_meta.show_meta_edit_page(meta, '/cgi-bin/EditObject.py',
                                 objID + '#' + str(version))
    return True
コード例 #2
0
def get_all_paths(objID, version, skipLock = False, searchFile = None,
             allowNullSearchFile = False):
    #searchFile = ryw_meta.open_search_file(RepositoryRoot)
    #if not searchFile:
    #    return (False, None)

    #meta,objroot = ryw_meta.get_meta(searchFile, objID, version,
    #                                 RepositoryRoot)
    #searchFile.done()

    if searchFile == None and not allowNullSearchFile:
        ryw.give_bad_news('DisplaySelection.get_path: warning, no ' +
                          'searchFile. ok but should fix.',
                          logging.warning)

    if searchFile:
        success,meta = searchFile.get_meta(objID, version)
        if success and meta:
            objroot = ryw_meta.get_objectstore_root(RepositoryRoot, meta)
    else:
        success,meta,objroot = ryw_meta.get_meta2(
            RepositoryRoot, objID, version, skipLk = skipLock)
        logging.warning('DisplaySelection.get_path: get_meta2 called.')

    if not success or (not meta and not objroot):
        ryw.give_bad_news(
            'DisplaySelection: no meta, no objroot, giving up...',
            logging.critical)
        return (False, None, None)

    paths = ryw_meta.get_paths(objroot, objID, version, meta, RepositoryRoot)
    if not paths:
        ryw.give_bad_news('DisplaySelection: failed to get paths.',
                          logging.critical)
        return (False, None, None)

    return (True, paths, meta)
コード例 #3
0
def main():
    # initialization.
    print_header()
    form = cgi.FieldStorage()
    setup_logging()

    # cgi.print_form(form)

    success,objID,version = ryw.get_obj_str2(form)
    if not success:
        ryw_upload.quick_exit(1)
    logging.debug('EditObject: ' + objID + '#' + str(version))

    if not ryw_meta.check_required_fields(form):
        ryw_upload.quick_exit(1)

    success,meta,objroot = ryw_meta.get_meta2(RepositoryRoot,
                                                  objID, version)
    if not success:
        ryw_upload.quick_exit(1)



    reext = re_extract_or_not(form)
    if reext:
        paths = ryw_meta.get_paths(objroot, objID, version,
                                   meta, RepositoryRoot)
        if not paths:
            ryw.give_bad_news('EditObject: failed to get paths.',
                              logging.critical)
            ryw_upload.quick_exit(1)

        dataPath = paths[0]
        fileName = get_file_name(dataPath)
        if not fileName:
            reext = False



    success = ryw_meta.process_error_fields(form, meta)
    if not success:
        ryw_upload.quick_exit(1)

    ryw_meta.process_fields(form, meta)
    logging.debug('EditObjects: ' + repr(meta))

    meta = ryw_upload.get_change_date_time(meta)

    #ryw.give_news(repr(meta), logging.info)



    if reext:
        re_extract(dataPath, fileName, meta)


    success,searchFile = do_update_metadata(objroot, objID, version, meta)
    if not success:
        ryw_upload.quick_exit(1)


    show_one_server_object(meta, searchFile)
    ryw.give_good_news('edit completed.', logging.info)

    ryw_view.print_footer()

    if searchFile:
        searchFile.done()
    sys.exit(0)