tilie_server.routers.files#
The user’s files below the server’s root folder: list, read and write.
GET /api/folders lists one folder, GET /api/files reads a file and
PUT /api/files writes one (decisions/0033-server-file-access.md).
A path is the query parameter path, POSIX and relative to the root,
"" the root itself. Every path is resolved, each symbolic link followed,
and refused when it does not lie in the root or names a hidden place below
it (a segment starting with .). Only the files TimeLineEditor opens are
read and listed, workspace, manifest and table files, and only the one it
saves through the server is written, the workspace file.
- tilie_server.routers.files.READ_KINDS = ('.tle.json', '.yaml', '.yml', '.json', '.parquet')#
The ends of the names TimeLineEditor lists and reads, matched in any case.
- tilie_server.routers.files.WRITTEN_KINDS = ('.tle.json',)#
The ends of the names TimeLineEditor writes, matched in any case: workspace files.
- exception tilie_server.routers.files.Refused(refusal)[source]#
Bases:
ExceptionA request for a path the routes do not serve, with its status and message.
- tilie_server.routers.files.is_kind(name, kinds)[source]#
Whether a file named
nameends in one ofkinds, in any case.
Whether one of the segments
partsstarts with.and is not...
- tilie_server.routers.files.resolve(path)[source]#
The absolute path
pathnames, every link followed but one in a loop.A link in a loop is left in the path unresolved, with the segments after it, on every Python version:
Path.resolvedoes so from Python 3.13 on but raisesRuntimeErrorup to 3.12, so this calls the function it builds on,os.path.realpath, which leaves the loop in place everywhere.status_ofthen finds the link, or nothing behind it.
- tilie_server.routers.files.inside(root, path)[source]#
The absolute path
pathnames belowroot, every link followed.- Parameters:
- Raises:
Refused –
pathis absolute, holds a NUL character, or resolves to a place that does not lie in the root (through..or a symbolic link leading out); it has a hidden segment, or resolves to a place with one below the root; or its links form a loop.- Return type:
- tilie_server.routers.files.status_of(path, follow=True)[source]#
What lies at
path,Nonefor nothing (or links in a loop)."folder","file","other", or"link"whenfollowis false and the path names a symbolic link itself.
- tilie_server.routers.files.file_path(root, path, kinds, refusal)[source]#
The file
pathnames belowroot, its name and its target’s ofkinds.
- tilie_server.routers.files.listing(root, path)[source]#
The folders, then the files of a kind TimeLineEditor reads, in
path.Hidden names are left out, and so is a symbolic link leading out of the root, into a hidden place, to nothing, or to a file of another kind; a link inside the root is listed as what it leads to. Each group is sorted by code point.
- tilie_server.routers.files.write(root, path, body)[source]#
Write
bodyinto the workspace filepathnames, replacing it whole.The bytes go to a new file beside it, which then takes the file’s place (
os.replace), so the file is never seen half written. A file replaced keeps its mode; a new one is created asopencreates it, under the process’s umask.- Raises:
Refused – The path is refused as
insiderefuses, ends in/, names (or leads through a link to) a file that is no workspace file, lies in no existing folder, names a folder, or names a file or lies in a folder the user may not write.- Parameters:
- Return type:
- tilie_server.routers.files.root_of(request)[source]#
The run’s resolved root folder.
- Parameters:
request (Request)
- Return type:
- tilie_server.routers.files.get_folder(request, path='')[source]#
List the folder
path.- Parameters:
request (Request)
path (str)
- Return type:
Response