mud_server.api.routes.lab_support

Shared helpers for lab route preconditions and response assembly.

This module keeps the lab router focused on HTTP registration while centralising repeated session, world, and translation-layer checks.

Functions

require_lab_role(role)

Raise 403 if the role's hierarchy level is below admin.

require_lab_session(session_id)

Validate one session id and enforce the minimum lab role.

get_lab_world(engine, world_id)

Return an active world or raise a 404 lab-style error.

require_translation_world(world, world_id, *[, ...])

Return one world's translation service or raise an HTTP error.

require_world_root(world, *, unavailable_detail)

Return the world root directory or raise a 404 with route-specific detail.

build_lab_world_config(world_id, service)

Construct the stable lab-facing world config payload.

load_world_json(world, *, unavailable_detail)

Return the resolved world.json path and parsed payload for one world.

write_world_json(path, payload)

Persist one world.json payload using repo-standard formatting.

Module Contents

mud_server.api.routes.lab_support.require_lab_role(role)[source]

Raise 403 if the role’s hierarchy level is below admin.

mud_server.api.routes.lab_support.require_lab_session(session_id)[source]

Validate one session id and enforce the minimum lab role.

Returns:

The validated role string for the current session.

Return type:

str

mud_server.api.routes.lab_support.get_lab_world(engine, world_id)[source]

Return an active world or raise a 404 lab-style error.

mud_server.api.routes.lab_support.require_translation_world(world, world_id, *, status_code=404)[source]

Return one world’s translation service or raise an HTTP error.

mud_server.api.routes.lab_support.require_world_root(world, *, unavailable_detail)[source]

Return the world root directory or raise a 404 with route-specific detail.

mud_server.api.routes.lab_support.build_lab_world_config(world_id, service)[source]

Construct the stable lab-facing world config payload.

mud_server.api.routes.lab_support.load_world_json(world, *, unavailable_detail)[source]

Return the resolved world.json path and parsed payload for one world.

mud_server.api.routes.lab_support.write_world_json(path, payload)[source]

Persist one world.json payload using repo-standard formatting.