websauna.utils.slug module¶
Utilities to encode and decode UUID objects as URL parameters.
We provide UUID to Base64 encoded string and back coding.
More information what term slug means.
-
exception
websauna.utils.slug.
SlugDecodeError
[source]¶ Bases:
Exception
Raised when you pass invalid b64 slug data.
-
websauna.utils.slug.
slug_to_uuid
(slug)[source]¶ Convert UUID URL slug string to UUID object.
This method raises ValueError if slug cannot be converted to UUID:
try: # Is like 'I0p4RyoIQe-EQ1GU_QicoQ' delivery_uuid = slug_to_uuid(art_data["cartID"]) except SlugDecodeError as e: return HTTPNotFound("UUID was not a well-formed base64 encoded slug") from e