def main():
    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('CurrSelAddedToThisSel: entered...')
    ryw_view.print_header_logo()


    success,objID,version = ryw.get_obj_str()
    if not success:
        ryw.give_bad_news('CurrSelToThisSel: failed to get objstr.',
                          logging.critical)
        DisplaySelection.exit_now(1)
    
    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists('CurrSelAddedToThisSel:')
    if not success:
        ryw.give_bad_news('CurrSelAddedToThisSel: ' +
                          'open_searchfile_reverselists failed.',
                          logging.critical)
        DisplaySelection.exit_now(1)
    

    rfpath = DisplaySelection.get_file_path(
        objID, version, searchFile = searchFile)
    if not rfpath:
        ryw.give_bad_news(
            'CurrSelAddedToThisSel: no selection file name found.',
            logging.error)
        DisplaySelection.exit_now(1)

    queueName = DeleteRepReq.get_queue_name()
    if not queueName:
        ryw.give_bad_news(
            'CurrSelToThisSel: failed to get current selection file name.',
            logging.error)
        DisplaySelection.exit_now(1)

    queueSel = ProcessDownloadReq.get_reqs(queueName)
    savedSel = ProcessDownloadReq.get_reqs(rfpath)
    newContainees = list(queueSel)

    AddSearchAll.union_and_write(savedSel, queueSel, rfpath)
    ryw.give_news('You may want to reload the page containing '+
                  'this selection.', logging.info)


    success = reverseLists.add(objID+'#'+str(version), newContainees)
    if not success:
        ryw.give_bad_news('CurrSelAddedToThisSel: reverseLists.add failed.',
                          logging.critical)

    reverseLists.done()
    searchFile.done()
    DisplaySelection.exit_now(0)
def get_file_path(searchFile = None, allowNullSearchFile = False):
    success,objID,version = ryw.get_obj_str()
    if not success:
        ryw.give_bad_news('ThisSelToCurrSel: failed to get objstr.',
                          logging.critical)
        return None

    rfpath = DisplaySelection.get_file_path(
        objID, version, searchFile = searchFile,
        allowNullSearchFile = allowNullSearchFile)
    return rfpath
예제 #3
0
def main():
    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('DeleteFromSel: entered...')
    ProcessDownloadReq.print_header()

    #ProcessDownloadReq.delete_request(queue)

    form = cgi.FieldStorage()
    if (not form.has_key('objstr')) or (not form.has_key('selobj')):
        ryw.give_bad_news('DeleteFromSel.py: lacking arguments.',
                          logging.critical)
        DisplaySelection.exit_now(1)
        
    objstr = form.getfirst('objstr', '')
    selobj = form.getfirst('selobj', '')

    if (not objstr) or (not selobj):
        ryw.give_bad_news('DeleteFromSel.py: null arguments.',
                          logging.critical)
        DisplaySelection.exit_now(1)

    #ryw.give_news('DeleteFromSel.py: ' + objstr, logging.info)
    #ryw.give_news('DeleteFromSel.py: ' + selobj, logging.info)


    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists('DeleteFromSel:')
    if not success:
        ryw.give_bad_news(
            'DeleteFromSel: open_searchfile_reverselists failed.',
            logging.critical)
        DisplaySelection.exit_now(1)


    objID,version = selobj.split('#')
    version = int(version)
    rfpath = DisplaySelection.get_file_path(objID, version,
                                            searchFile=searchFile)
    if not rfpath:
        DisplaySelection.exit_now(1)

    success = ProcessDownloadReq.do_delete(rfpath, objstr)

    if success:
        sys.stdout.write("True")
    else:
        print "Failed to delete from selection."

    reverseLists.remove_obsolete_containers(objstr, [selobj])
    reverseLists.done()
def main():
    ryw.check_logging(os.path.join(RepositoryRoot, 'WWW', 'logs'),
                      'upload.log')
    logging.debug('CurrSelToThisSel: entered...')
    ryw_view.print_header_logo()


    success,objID,version = ryw.get_obj_str()
    if not success:
        ryw.give_bad_news('CurrSelToThisSel: failed to get objstr.',
                          logging.critical)
        DisplaySelection.exit_now(1)
    
    success,searchFile,reverseLists = \
        ReverseLists.open_searchfile_reverselists('CurrSelToThisSel:')
    if not success:
        ryw.give_bad_news('CurrSelToThisSel: ' +
                          'open_searchfile_reverselists failed.',
                          logging.critical)
        DisplaySelection.exit_now(1)
    

    rfpath = DisplaySelection.get_file_path(
        objID, version, searchFile = searchFile)
    if not rfpath:
        ryw.give_bad_news(
            'CurrSelToThisSel: no selection file name found.',
            logging.error)
        DisplaySelection.exit_now(1)
    oldContainees = ShowQueue.read_list(rfpath)

    queueName = DeleteRepReq.get_queue_name()
    if not queueName:
        ryw.give_bad_news(
            'CurrSelToThisSel: failed to get current selection file name.',
            logging.error)
        DisplaySelection.exit_now(1)
    newContainees = ShowQueue.read_list(queueName)

    try:
        shutil.copyfile(queueName, rfpath)
    except:
        ryw.give_bad_news('CurrSelToThisSel: failed to overwrite: ' +
                          queueName + ' -> ' + rfpath,
                          logging.critical)
        DisplaySelection.exit_now(1)

    ryw.give_news(
        'The current selection successfully loaded as this selection.',
        logging.info)
    ryw.give_news('You may want to reload the page containing '+
                  'this selection.', logging.info)

    success = reverseLists.redefine_container(
        objID+'#'+str(version), oldContainees, newContainees)
    if not success:
        ryw.give_bad_news('CurrSelToThisSel: ' +
                          'reverseLists.redefine_container failed.',
                          logging.critical)

    reverseLists.done()
    searchFile.done()
    ryw_view.print_footer()