예제 #1
0
def test_get_specific_records(app, sample_record_xml):
    """Test that getting records via identifiers work with prefix."""
    def foo(request, records, name):
        assert len(records) == 1

    responses.add(
        responses.GET,
        'http://export.arxiv.org/oai2',
        body=sample_record_xml,
        content_type='text/xml'
    )
    oaiharvest_finished.connect(foo)
    try:
        with app.app_context():
            get_specific_records(
                'oai:arXiv.org:1507.03011',
                metadata_prefix="arXiv",
                url='http://export.arxiv.org/oai2'
            )
            # As a list of identifiers
            get_specific_records(
                ['oai:arXiv.org:1507.03011'],
                metadata_prefix="arXiv",
                url='http://export.arxiv.org/oai2'
            )
    finally:
        oaiharvest_finished.disconnect(foo)
예제 #2
0
파일: ext.py 프로젝트: jma/rero-ils
    def register_signals(self, app):
        """Register signals."""
        # TODO: use before_record_index.dynamic_connect() if it works
        # example:
        # before_record_index.dynamic_connect(
        #    enrich_patron_data, sender=app, index='patrons-patron-v0.0.1')
        before_record_index.connect(enrich_collection_data, sender=app)
        before_record_index.connect(enrich_loan_data, sender=app)
        before_record_index.connect(enrich_document_data, sender=app)
        before_record_index.connect(enrich_contributions_data, sender=app)
        before_record_index.connect(enrich_item_data, sender=app)
        before_record_index.connect(enrich_patron_data, sender=app)
        before_record_index.connect(enrich_location_data, sender=app)
        before_record_index.connect(enrich_holding_data, sender=app)
        before_record_index.connect(enrich_notification_data, sender=app)
        before_record_index.connect(enrich_patron_transaction_event_data,
                                    sender=app)
        before_record_index.connect(enrich_patron_transaction_data, sender=app)
        before_record_index.connect(enrich_ill_request_data, sender=app)

        after_record_insert.connect(create_subscription_patron_transaction)
        after_record_update.connect(create_subscription_patron_transaction)

        loan_state_changed.connect(listener_loan_state_changed, weak=False)

        oaiharvest_finished.connect(publish_harvested_records, weak=False)

        apiharvest_part.connect(publish_api_harvested_records, weak=False)

        # invenio-userprofiles signal
        after_profile_update.connect(update_from_profile)
예제 #3
0
파일: ext.py 프로젝트: weblate/sonar
    def init_app(self, app):
        """Flask application initialization."""
        self.init_config(app)
        app.extensions['sonar_documents'] = self

        # Connect to oaiharvester signal
        oaiharvest_finished.connect(transform_harvested_records, weak=False)

        # Connect to record index signal, to modify record before indexing.
        before_record_index.connect(populate_fulltext_field, weak=False)
예제 #4
0
    def register_signals(self):
        """Register signals."""
        before_record_index.connect(enrich_loan_data)
        before_record_index.connect(enrich_document_data)

        item_at_desk.connect(listener_item_at_desk)

        oaiharvest_finished.connect(publish_harvested_records, weak=False)

        apiharvest_part.connect(publish_api_harvested_records, weak=False)

        after_record_insert.connect(mef_person_insert)
        after_record_update.connect(mef_person_update)
        after_record_delete.connect(mef_person_delete)
        after_record_revert.connect(mef_person_revert)
예제 #5
0
    def init_app(self, app):
        """Flask application initialization."""
        self.init_config(app)
        app.extensions['sonar_documents'] = self

        # Connect to oaiharvester signal
        oaiharvest_finished.connect(transform_harvested_records, weak=False)
        oaiharvest_finished.connect(export_json, weak=False)

        # Connect to record index signal, to modify record before indexing.
        before_record_index.connect(enrich_document_data, weak=False)

        # Adds `_oai` property
        before_record_insert.connect(update_oai_property)
        before_record_update.connect(update_oai_property)
예제 #6
0
파일: ext.py 프로젝트: rerowep/rero-ils
    def register_signals(self, app):
        """Register signals."""
        # TODO: use before_record_index.dynamic_connect() if it works
        # example:
        # before_record_index.dynamic_connect(
        #    enrich_patron_data, sender=app, index='patrons-patron-v0.0.1')
        before_record_index.connect(enrich_acq_account_data, sender=app)
        before_record_index.connect(enrich_acq_order_data, sender=app)
        before_record_index.connect(enrich_acq_receipt_data, sender=app)
        before_record_index.connect(enrich_acq_receipt_line_data, sender=app)
        before_record_index.connect(enrich_acq_order_line_data, sender=app)
        before_record_index.connect(enrich_collection_data, sender=app)
        before_record_index.connect(enrich_loan_data, sender=app)
        before_record_index.connect(enrich_document_data, sender=app)
        before_record_index.connect(enrich_contributions_data, sender=app)
        before_record_index.connect(enrich_item_data, sender=app)
        before_record_index.connect(enrich_patron_data, sender=app)
        before_record_index.connect(enrich_location_data, sender=app)
        before_record_index.connect(enrich_holding_data, sender=app)
        before_record_index.connect(enrich_notification_data, sender=app)
        before_record_index.connect(enrich_patron_transaction_event_data,
                                    sender=app)
        before_record_index.connect(enrich_patron_transaction_data, sender=app)
        before_record_index.connect(enrich_ill_request_data, sender=app)
        before_record_index.connect(prepare_template_data, sender=app)

        after_record_insert.connect(create_subscription_patron_transaction)
        after_record_update.connect(create_subscription_patron_transaction)
        after_record_update.connect(update_items_locations_and_types)

        before_record_update.connect(budget_is_active_changed)
        before_record_update.connect(negative_availability_changes)

        loan_state_changed.connect(listener_loan_state_changed, weak=False)

        oaiharvest_finished.connect(publish_harvested_records, weak=False)

        apiharvest_part.connect(publish_api_harvested_records, weak=False)

        # invenio-userprofiles signal
        after_profile_update.connect(update_from_profile)

        # store the username in the session
        user_logged_in.connect(set_user_name)
        user_logged_out.connect(remove_user_name)
        user_loaded_from_cookie.connect(set_user_name)
예제 #7
0
    def register_signals(self):
        """Register signals."""
        from invenio_indexer.signals import before_record_index
        from .loans.listener import enrich_loan_data
        before_record_index.connect(enrich_loan_data)
        from .documents.listener import enrich_document_data
        before_record_index.connect(enrich_document_data)

        from .patrons.listener import listener_item_at_desk
        from .items.signals import item_at_desk
        item_at_desk.connect(listener_item_at_desk)

        from invenio_oaiharvester.signals import oaiharvest_finished
        from .ebooks.receivers import publish_harvested_records
        oaiharvest_finished.connect(publish_harvested_records, weak=False)

        from .apiharvester.signals import apiharvest_part
        from .mef_persons.receivers import publish_api_harvested_records
        apiharvest_part.connect(publish_api_harvested_records, weak=False)
예제 #8
0
    def register_signals(self):
        """Register signals."""
        before_record_index.connect(enrich_loan_data)
        before_record_index.connect(enrich_document_data)
        before_record_index.connect(enrich_item_data)
        before_record_index.connect(enrich_patron_data)
        before_record_index.connect(enrich_location_data)
        before_record_index.connect(enrich_holding_data)
        before_record_index.connect(enrich_notification_data)

        loan_state_changed.connect(listener_loan_state_changed, weak=False)

        oaiharvest_finished.connect(publish_harvested_records, weak=False)

        apiharvest_part.connect(publish_api_harvested_records, weak=False)

        after_record_insert.connect(mef_person_insert)
        after_record_update.connect(mef_person_update)
        after_record_delete.connect(mef_person_delete)
        after_record_revert.connect(mef_person_revert)
예제 #9
0
def test_list_records_from_dates(app, sample_list_xml):
    """Check harvesting of records from multiple setspecs."""
    def bar(request, records, name):
        assert len(records) == 150

    responses.add(
        responses.GET,
        re.compile(r'http?://export.arxiv.org/oai2.*set=physics.*'),
        body=sample_list_xml,
        content_type='text/xml'
    )
    oaiharvest_finished.connect(bar)
    try:
        with app.app_context():
            list_records_from_dates(
                metadata_prefix='arXiv',
                from_date='2015-01-15',
                until_date='2015-01-20',
                url='http://export.arxiv.org/oai2',
                name=None,
                setspecs='physics'
            )
    finally:
        oaiharvest_finished.disconnect(bar)
예제 #10
0
파일: ext.py 프로젝트: jma/rero-ebooks
 def register_signals(app):
     """Register Zenodo Deposit signals."""
     oaiharvest_finished.connect(publish_harvested_records, weak=False)
예제 #11
0
 def register_signals(app):
     """Register Zenodo Deposit signals."""
     oaiharvest_finished.connect(publish_harvested_records, weak=False)
     before_record_index.connect(indexer_receiver, weak=False)
예제 #12
0
 def register_signals(self):
     """Register signals."""
     from .items.signals import item_at_desk
     from .patrons.listener import listener_item_at_desk
     item_at_desk.connect(listener_item_at_desk)
     oaiharvest_finished.connect(publish_harvested_records, weak=False)