def id_minter(record_uuid, data, provider, pid_key='pid', object_type='rec'): """Document PID minter.""" # Create persistent identifier provider = provider.create(object_type=object_type, object_uuid=record_uuid, pid_value=data.get(pid_key)) pid = provider.pid data[pid_key] = pid.pid_value # Mandatory to check if PID for OAI exists, as the minter is called twice # during API calls.. try: oai_pid_value = current_app.config.get('OAISERVER_ID_PREFIX', '') + str(pid.pid_value) OAIIDProvider.get(oai_pid_value, 'oai') except PIDDoesNotExistError: oaiid_minter(record_uuid, data) return pid