httk.serve.http.identifiers

Wire-format identifier and timestamp primitives shared across serving protocols.

These helpers carry no protocol vocabulary: they normalise a UUID factory result to the urn:uuid: URN form, render a timezone-aware datetime as an XSD/RFC 3339 UTC timestamp, and report whether a string is free of lone UTF-16 surrogate code points. Protocol packages such as httk.serve.dsp consume them for on-the-wire message construction.

Functions

is_json_encodable_text(value)

Report whether a string is free of lone UTF-16 surrogate code points.

urn_uuid(value)

Normalise a UUID factory result to the required urn:uuid: URN form.

xsd_utc_timestamp(value)

Render a timezone-aware datetime as an XSD/RFC 3339 UTC timestamp.

Module Contents

httk.serve.http.identifiers.is_json_encodable_text(value)[source]

Report whether a string is free of lone UTF-16 surrogate code points.

Parameters:

value (str) – String to test for lone surrogate code points.

Returns:

False when the string contains a lone surrogate, otherwise True.

Return type:

bool

httk.serve.http.identifiers.urn_uuid(value)[source]

Normalise a UUID factory result to the required urn:uuid: URN form.

Parameters:

value (object) – UUID factory output rendered to text before normalisation.

Returns:

The identifier in urn:uuid: form.

Raises:

RuntimeError – If the rendered value is blank or contains a lone surrogate.

Return type:

str

httk.serve.http.identifiers.xsd_utc_timestamp(value)[source]

Render a timezone-aware datetime as an XSD/RFC 3339 UTC timestamp.

Parameters:

value (datetime.datetime) – Timezone-aware datetime to render as a UTC XML Schema date-time.

Returns:

The value in UTC with a Z suffix.

Raises:
Return type:

str