def update_records(resource_type, resource):
    logger.debug('update_records %s %s', resource_type, resource)
    adapter = OaiAdapter()
    try:
        (resource_id, identifier, datestamp, set_spec, public) = adapter.get_record(resource_type, resource)
    except TypeError:
        raise RuntimeError(('Could not obtain record for %s %s' % (resource_type, resource)))
    if (public is True):
        for metadata_prefix in adapter.resource_types[resource_type]:
            try:
                record = Record.objects.get(identifier=identifier, metadata_prefix=metadata_prefix)
            except Record.DoesNotExist:
                record = Record(identifier=identifier, metadata_prefix=metadata_prefix)
            record.datestamp = datestamp
            record.set_spec = set_spec
            record.deleted = False
            record.resource_type = resource_type
            record.resource_id = resource_id
            record.save()
    else:
        delete_records(resource_type, resource)
def update_records(resource_type, resource):
    logger.debug('update_records %s %s', resource_type, resource)
    adapter = OaiAdapter()
    try:
        (resource_id, identifier, datestamp, set_spec, public) = adapter.get_record(resource_type, resource)
    except TypeError:
        raise RuntimeError(('Could not obtain record for %s %s' % (resource_type, resource)))
    if (public is True):
        for metadata_prefix in adapter.resource_types[resource_type]:
            try:
                record = Record.objects.get(identifier=identifier, metadata_prefix=metadata_prefix)
            except Record.DoesNotExist:
                record = Record(identifier=identifier, metadata_prefix=metadata_prefix)
            record.datestamp = datestamp
            record.set_spec = set_spec
            record.deleted = False
            record.resource_type = resource_type
            record.resource_id = resource_id
            record.save()
    else:
        delete_records(resource_type, resource)