clarin.sru.server.config

class clarin.sru.server.config.LegacyNamespaceMode(value)[source]

Bases: str, Enum

An enumeration.

LOC = 'loc'
OASIS = 'oasis'
class clarin.sru.server.config.LocalizedString(value: str, lang: str, primary: bool = False)[source]

Bases: object

value: str
lang: str
primary: bool = False
class clarin.sru.server.config.SRUServerConfigKey(value)[source]

Bases: str, Enum

An enumeration.

SRU_SUPPORTED_VERSION_MIN = 'eu.clarin.sru.server.sruSupportedVersionMin'

Parameter constant for setting the minimum supported SRU version for this SRU server. Must be smaller or equal to SRU_SUPPORTED_VERSION_MAX.

Valid values: “1.1”, “1.2” or ” 2.0” (without quotation marks)

SRU_SUPPORTED_VERSION_MAX = 'eu.clarin.sru.server.sruSupportedVersionMax'

Parameter constant for setting the maximum supported SRU version for this SRU server. Must be larger or equal to SRU_SUPPORTED_VERSION_MIN.

Valid values: “1.1”, “1.2” or “2.0” (without quotation marks)

SRU_SUPPORTED_VERSION_DEFAULT = 'eu.clarin.sru.server.sruSupportedVersionDefault'

Parameter constant for setting the default SRU version for this SRU server, e.g. for an Explain request without explicit version.

Must not me less than SRU_SUPPORTED_VERSION_MIN or larger than SRU_SUPPORTED_VERSION_MAX. Defaults to SRU_SUPPORTED_VERSION_MAX.

Valid values: “1.1”, “1.2” or “2.0” (without quotation marks)

SRU_LEGACY_NAMESPACE_MODE = 'eu.clarin.sru.server.legacyNamespaceMode'

Parameter constant for setting the namespace URIs for SRU 1.1 and SRU 1.2.

Valid values: “loc” for Library Of Congress URI or “oasis” for OASIS URIs (without quotation marks).

SRU_TRANSPORT = 'eu.clarin.sru.server.transport'

Parameter constant for configuring the transports for this SRU server.

Valid values: “http”, “https” or “http https” (without quotation marks)

Used as part of the Explain response.

SRU_HOST = 'eu.clarin.sru.server.host'

Parameter constant for configuring the host of this SRU server.

Valid values: any fully qualified hostname, e.g. sru.example.org.

Used as part of the Explain response.

SRU_PORT = 'eu.clarin.sru.server.port'

Parameter constant for configuring the port number of this SRU server.

Valid values: number between 1 and 65535 (typically 80 or 8080)

Used as part of the Explain response.

SRU_DATABASE = 'eu.clarin.sru.server.database'

Parameter constant for configuring the database of this SRU server. This is usually the path component of the SRU servers URI.

Valid values: typically the path component if the SRU server URI.

Used as part of the Explain response.

SRU_NUMBER_OF_RECORDS = 'eu.clarin.sru.server.numberOfRecords'

Parameter constant for configuring the default number of records the SRU server will provide in the response to a searchRetrieve request if the client does not provide this value.

Valid values: a integer greater than 0 (default value is 100)

SRU_MAXIMUM_RECORDS = 'eu.clarin.sru.server.maximumRecords'

Parameter constant for configuring the maximum number of records the SRU server will support in the response to a searchRetrieve request. If a client requests more records, the number will be limited to this value.

Valid values: a integer greater than 0 (default value is 250)

SRU_NUMBER_OF_TERMS = 'eu.clarin.sru.server.numberOfTerms'

Parameter constant for configuring the default number of terms the SRU server will provide in the response to a scan request if the client does not provide this value.

Valid values: a integer greater than 0 (default value is 250)

SRU_MAXIMUM_TERMS = 'eu.clarin.sru.server.maximumTerms'

Parameter constant for configuring the maximum number of terms the SRU server will support in the response to a scan request. If a client requests more records, the number will be limited to this value.

Valid values: a integer greater than 0 (default value is 500)

SRU_ECHO_REQUESTS = 'eu.clarin.sru.server.echoRequests'

Parameter constant for configuring, if the SRU server will echo the request.

Valid values: true or false

SRU_INDENT_RESPONSE = 'eu.clarin.sru.server.indentResponse'

Parameter constant for configuring, if the SRU server pretty-print the XML response. Setting this parameter can be useful for manual debugging of the XML response, however it is not recommended for production setups.

Valid values: any integer greater or equal to -1 (default) and less or equal to 8

SRU_ALLOW_OVERRIDE_MAXIMUM_RECORDS = 'eu.clarin.sru.server.allowOverrideMaximumRecords'

Parameter constant for configuring, if the SRU server will allow the client to override the maximum number of records the server supports. This parameter is solely intended for debugging and setting it to true is strongly discouraged for production setups.

Valid values: true or false (default)

SRU_ALLOW_OVERRIDE_MAXIMUM_TERMS = 'eu.clarin.sru.server.allowOverrideMaximumTerms'

Parameter constant for configuring, if the SRU server will allow the client to override the maximum number of terms the server supports. This parameter is solely intended for debugging and setting it to true it is strongly discouraged for production setups.

Valid values: true or false (default)

SRU_ALLOW_OVERRIDE_INDENT_RESPONSE = 'eu.clarin.sru.server.allowOverrideIndentResponse'

Parameter constant for configuring, if the SRU server will allow the client to override the pretty-printing setting of the server. This parameter is solely intended for debugging and setting it to true it is strongly discouraged for production setups.

Valid values: true or false (default)

SRU_RESPONSE_BUFFER_SIZE = 'eu.clarin.sru.server.responseBufferSize'

Parameter constant for configuring the size of response buffer. The Servlet will buffer up to this amount of data before sending a response to the client. This value specifies the size of the buffer in bytes.

Valid values: any positive integer (default 65536)

class clarin.sru.server.config.DatabaseInfo(title: List[clarin.sru.server.config.LocalizedString] | NoneType = None, description: List[clarin.sru.server.config.LocalizedString] | NoneType = None, author: List[clarin.sru.server.config.LocalizedString] | NoneType = None, extent: List[clarin.sru.server.config.LocalizedString] | NoneType = None, history: List[clarin.sru.server.config.LocalizedString] | NoneType = None, langUsage: List[clarin.sru.server.config.LocalizedString] | NoneType = None, restrictions: List[clarin.sru.server.config.LocalizedString] | NoneType = None, subjects: List[clarin.sru.server.config.LocalizedString] | NoneType = None, links: List[clarin.sru.server.config.LocalizedString] | NoneType = None, implementation: List[clarin.sru.server.config.LocalizedString] | NoneType = None)[source]

Bases: object

title: List[LocalizedString] | None = None
description: List[LocalizedString] | None = None
author: List[LocalizedString] | None = None
extent: List[LocalizedString] | None = None
history: List[LocalizedString] | None = None
langUsage: List[LocalizedString] | None = None
restrictions: List[LocalizedString] | None = None
subjects: List[LocalizedString] | None = None
implementation: List[LocalizedString] | None = None
class clarin.sru.server.config.SchemaInfo(identifier: str, name: str, location: str, sort: bool, retrieve: bool, title: List[clarin.sru.server.config.LocalizedString] | NoneType = None)[source]

Bases: object

identifier: str
name: str
location: str
sort: bool
retrieve: bool
title: List[LocalizedString] | None = None
class clarin.sru.server.config.IndexInfo(sets: List[clarin.sru.server.config.IndexInfo.Set] | NoneType = None, indexes: List[clarin.sru.server.config.IndexInfo.Index] | NoneType = None)[source]

Bases: object

class Set(identifier: str, name: str, title: List[clarin.sru.server.config.LocalizedString] | NoneType = None)[source]

Bases: object

identifier: str
name: str
title: List[LocalizedString] | None = None
class Index(can_search: bool, can_scan: bool, can_sort: bool, maps: List[clarin.sru.server.config.IndexInfo.Index.Map] | NoneType = None, title: List[clarin.sru.server.config.LocalizedString] | NoneType = None)[source]

Bases: object

class Map(primary: bool, set: str, name: str)[source]

Bases: object

primary: bool
set: str
name: str
can_scan: bool
can_sort: bool
maps: List[Map] | None = None
title: List[LocalizedString] | None = None
sets: List[Set] | None = None
indexes: List[Index] | None = None
class clarin.sru.server.config.SRUServerConfig(min_version: SRUVersion, max_version: SRUVersion, default_version: SRUVersion, legacy_namespace_mode: LegacyNamespaceMode, transport: str, host: str, port: int, database: str, number_of_records: int, maximum_records: int, number_of_terms: int, maximum_terms: int, echo_requests: bool, indent_response: int, response_buffer_size: int, allow_override_maximum_records: bool, allow_override_maximum_terms: bool, allow_override_indent_response: bool, database_info: DatabaseInfo, index_info: IndexInfo, schema_info: List[SchemaInfo] | None = None)[source]

Bases: object

SRU server configuration.

The XML configuration file must validate against the sru-server-config.xsd W3C schema bundled with the package and need to have the http://www.clarin.eu/sru-server/1.0/ XML namespace.

min_version: SRUVersion
max_version: SRUVersion
default_version: SRUVersion
legacy_namespace_mode: LegacyNamespaceMode
transport: str
host: str
port: int
database: str
number_of_records: int
maximum_records: int
number_of_terms: int
maximum_terms: int
echo_requests: bool
indent_response: int
response_buffer_size: int
allow_override_maximum_records: bool
allow_override_maximum_terms: bool
allow_override_indent_response: bool
base_url: str
database_info: DatabaseInfo
index_info: IndexInfo
schema_info: List[SchemaInfo] | None = None
property default_record_xml_escaping: SRURecordXmlEscaping
property default_record_packing: SRURecordPacking
get_record_schema_identifier(record_schema_name: str) str | None[source]
get_record_schema_name(schema_identifier: str) str | None[source]
find_schema_info(value: str) SchemaInfo | None[source]
static find_set_by_name(sets: List[Set], name: str) Set | None[source]
static fromparams(params: Dict[str, str], database_info: DatabaseInfo, index_info: IndexInfo | None = None, schema_info: List[SchemaInfo] | None = None) SRUServerConfig[source]

Creates an SRU configuration object with default values and overrides from params.

Parameters:
  • params – additional settings

  • database_info – optinal DatabaseInfo

  • index_info – optinal IndexInfo

  • schema_info – optional list SchemaInfo

Returns:

SRUServerConfig – a initialized SRUEndpointConfig instance

Raises:
static parse(params: Dict[str, str], config_file: BytesIO | PathLike | str) SRUServerConfig[source]

Parse a SRU server XML configuration file and create an configuration object from it.

Parameters:
  • params – additional settings

  • config_file – an URL pointing to the XML configuration file

Returns:

SRUServerConfig – a initialized SRUEndpointConfig instance

Raises:
static load_config_file(config_file: BytesIO | PathLike | str) _ElementTree[source]
static parse_version(params: Dict[str, str], name: str, mandatory: bool, default: SRUVersion) SRUVersion[source]
static parse_int(params: Dict[str, str], name: str, mandatory: bool, default: int, min: int, max: int) int[source]
static parse_bool(params: Dict[str, str], name: str, mandatory: bool, default: bool) bool[source]