There is currently no way to get the internal path of a thing without the API prefix. Not to get the api_prefix from the server from public attributes.
From within a Thing
The OpenFlexure server saves data from each thing in a directory <data_dir>/self.path. As we add an API path of /api/v3 this means that we end up saving scans at <data_dir>/api/v3/smart_scan not <data_dir>/smart_scan.
This is fairly easily solved by using self.name rather than self.path, but this isn't future proof against in future being able to have "sub-Things" and nested paths.
It would be nice to have a way to either:
- read the api path from the
ThingServerInterface, or
- have something like
self.path be /smart_scan/ and self.full_path be /api/v3/smart_scan/ [Breaking change if we release this RC as 0.2.0]
- possibly
self.path be /api/v3/smart_scan/ and self.internal_path be /smart_scan/
From a function that has an instance of a ThingServer
When starting the server, we need to add API routes. To mount the data directory within the API path we need to read the prefix. We can do this from server._api_prefix. It would be ideal to have this read-only property part of the public API for the server class.
Details
There is currently no way to get the internal path of a thing without the API prefix. Not to get the api_prefix from the server from public attributes.
From within a Thing
The OpenFlexure server saves data from each thing in a directory
<data_dir>/self.path. As we add an API path of/api/v3this means that we end up saving scans at<data_dir>/api/v3/smart_scannot<data_dir>/smart_scan.This is fairly easily solved by using
self.namerather thanself.path, but this isn't future proof against in future being able to have "sub-Things" and nested paths.It would be nice to have a way to either:
ThingServerInterface, orself.pathbe/smart_scan/andself.full_pathbe/api/v3/smart_scan/[Breaking change if we release this RC as 0.2.0]self.pathbe/api/v3/smart_scan/andself.internal_pathbe/smart_scan/From a function that has an instance of a ThingServer
When starting the server, we need to add API routes. To mount the data directory within the API path we need to read the prefix. We can do this from
server._api_prefix. It would be ideal to have this read-only property part of the public API for the server class.Details