Exemple #1
0
def cli_revert_to_revision(revid):
    """Submit specified record revision REVID upload, to replace current
    version.

    """
    if not revision_format_valid_p(revid):
        print('ERROR: revision %s is invalid; ' \
              'must be NNN.YYYYMMDDhhmmss.' % revid)
        sys.exit(1)

    xml_record = get_marcxml_of_revision_id(revid)
    if xml_record == '':
        print('ERROR: Revision %s does not exist. ' % revid)
        sys.exit(1)

    recid = split_revid(revid)[0]

    if record_locked_by_other_user(recid, -1):
        print('The record is currently being edited. ' \
            'Please try again in a few minutes.')
        sys.exit(1)

    if record_locked_by_queue(recid):
        print('The record is locked because of unfinished upload tasks. ' \
            'Please try again in a few minutes.')
        sys.exit(1)

    save_xml_record(recid, 0, xml_record)
    print('Your modifications have now been submitted. They will be ' \
        'processed as soon as the task queue is empty.')
Exemple #2
0
def perform_candidate_record_search(requestType, data):
    """Handle search requests.
    """
    max_results = 999
    too_many = False
    result = {'resultCode': 0, 'resultText': ''}
    if requestType == "searchCandidates":
        recids = perform_request_search(p=data['query'])
        if len(recids) > max_results:
            too_many = True
        else:
            captions = [search_result_info(x) for x in recids]
            alternative_titles = [
                remove_html_markup(print_record(x, "hs")) for x in recids
            ]
            search_results = [recids, captions, alternative_titles]
    elif requestType == "searchRevisions":
        revisions = get_record_revision_ids(data['recID1'])
        captions = [split_revid(x, 'datetext')[1] for x in revisions]
        search_results = [revisions, captions]

    if too_many == True:
        result['resultCode'] = 1
        result['resultText'] = 'Too many results'
    else:
        result['results'] = search_results
        result['resultText'] = '%s results' % len(search_results[0])

    return result
Exemple #3
0
def cli_revert_to_revision(revid):
    """Submit specified record revision REVID upload, to replace current
    version.

    """
    if not revision_format_valid_p(revid):
        print('ERROR: revision %s is invalid; ' \
              'must be NNN.YYYYMMDDhhmmss.' % revid)
        sys.exit(1)

    xml_record = get_marcxml_of_revision_id(revid)
    if xml_record == '':
        print('ERROR: Revision %s does not exist. ' % revid)
        sys.exit(1)

    recid = split_revid(revid)[0]

    if record_locked_by_other_user(recid, -1):
        print('The record is currently being edited. ' \
            'Please try again in a few minutes.')
        sys.exit(1)

    if record_locked_by_queue(recid):
        print('The record is locked because of unfinished upload tasks. ' \
            'Please try again in a few minutes.')
        sys.exit(1)

    save_xml_record(recid, 0, xml_record)
    print('Your modifications have now been submitted. They will be ' \
        'processed as soon as the task queue is empty.')
Exemple #4
0
def perform_candidate_record_search(requestType, data):
    """Handle search requests.
    """
    max_results = 999
    too_many = False
    result = {
        'resultCode': 0,
        'resultText': ''
        }
    if requestType == "searchCandidates":
        recids = perform_request_search( p=data['query'] )
        if len(recids) > max_results:
            too_many = True
        else:
            captions = [ search_result_info(x) for x in recids ]
            alternative_titles = [ remove_html_markup(print_record(x, "hs")) for x in recids ]
            search_results = [recids, captions, alternative_titles]
    elif requestType == "searchRevisions":
        revisions = get_record_revision_ids( data['recID1'] )
        captions = [ split_revid(x, 'datetext')[1] for x in revisions ]
        search_results = [revisions, captions]

    if too_many == True:
        result['resultCode'] = 1
        result['resultText'] = 'Too many results'
    else:
        result['results'] = search_results
        result['resultText'] = '%s results' % len(search_results[0])

    return result