common
common
This module contains common logic, shared beyond all specialised parts of the QGIS-Server-Light interface.
BBox
dataclass
Bases: BaseInterface
Source code in src/qgis_server_light/interface/common.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
x_max: float = field(metadata={'type': 'Element'})
class-attribute
instance-attribute
x_min: float = field(metadata={'type': 'Element'})
class-attribute
instance-attribute
y_max: float = field(metadata={'type': 'Element'})
class-attribute
instance-attribute
y_min: float = field(metadata={'type': 'Element'})
class-attribute
instance-attribute
z_max: float = field(default=0.0, metadata={'type': 'Element'})
class-attribute
instance-attribute
z_min: float = field(default=0.0, metadata={'type': 'Element'})
class-attribute
instance-attribute
__init__(x_min: float, x_max: float, y_min: float, y_max: float, z_min: float = 0.0, z_max: float = 0.0) -> None
from_list(bbox_list: list[float]) -> BBox
staticmethod
Takes a list representation of a BBox in the form
[
Source code in src/qgis_server_light/interface/common.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
from_string(bbox_string: str) -> BBox
staticmethod
Takes a CSV string representation of a BBox in the form
'
Source code in src/qgis_server_light/interface/common.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
to_2d_list() -> list
Source code in src/qgis_server_light/interface/common.py
158 159 | |
to_2d_string() -> str
Source code in src/qgis_server_light/interface/common.py
161 162 | |
to_list() -> list
Source code in src/qgis_server_light/interface/common.py
152 153 | |
to_string() -> str
Source code in src/qgis_server_light/interface/common.py
155 156 | |
BaseInterface
dataclass
This class should be used as base class for all dataclasses in the interface. It offers useful methods to handle exposed content in a centralized way. Mainly for logging redaction.
Since dataclasses gets a repr method installed automatically when they are created, a dataclass inheriting from this base class has to be defined as follows:
@dataclass(repr=False)
class Config(BaseInterface):
id: int = field(metadata={"type": "Element"})
secure: str = field(metadata={"type": "Element"})
long_content: str = field(metadata={"type": "Element"})
@property
def shortened_fields(self) -> set:
return {"long_content"}
@property
def redacted_fields(self) -> set:
return {"secure"}
This way, when an instance of this example class gets logged somewhere it the output will be redacted, meaning the logging output might look like this:
Config(id=1, secure=**REDACTED**, long_content=abc12...io345)
Source code in src/qgis_server_light/interface/common.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
redacted_fields: set
property
Field which contents should get redacted before printing them on the log. This is mainly used to prevent passwords in logs.
Returns:
-
set–The set of field names which should be redacted
shorten_limit: int
property
The limit to which the content of a field should be shortened.
Returns:
-
int–The limit.
shortened_fields: set
property
Fields which should be shortened to a length, this is manly useful for large content fields with BLOB etc.
Returns:
-
set–The set field names which should be shortened.
__init__() -> None
__repr__()
Source code in src/qgis_server_light/interface/common.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
Crs
dataclass
Bases: BaseInterface
Source code in src/qgis_server_light/interface/common.py
218 219 220 221 222 223 224 225 226 227 228 229 | |
auth_id: str = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
axis_inverted: bool = field(default=False, metadata={'type': 'Element'})
class-attribute
instance-attribute
ogc_uri: str = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
ogc_urn: str = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
postgis_srid: int = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
__init__(auth_id: str = None, postgis_srid: int = None, ogc_uri: str = None, ogc_urn: str = None, axis_inverted: bool = False) -> None
RedactedString
This special string class can be used to handle secret strings in the application. It works like a normal string but in case it's used to print or log its value is not reveled to the output.
Source code in src/qgis_server_light/interface/common.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
__format__(format_spec)
Source code in src/qgis_server_light/interface/common.py
126 127 | |
__init__(value, redacted_text='**REDACTED**')
Source code in src/qgis_server_light/interface/common.py
116 117 118 | |
__json__()
Source code in src/qgis_server_light/interface/common.py
129 130 | |
__repr__()
Source code in src/qgis_server_light/interface/common.py
123 124 | |
__str__()
Source code in src/qgis_server_light/interface/common.py
120 121 | |
reveal()
Allows access to the original value when necessary.
Returns:
-
–
The secret string.
Source code in src/qgis_server_light/interface/common.py
132 133 134 135 136 137 138 139 140 | |
Style
dataclass
Bases: BaseInterface
Source code in src/qgis_server_light/interface/common.py
232 233 234 235 236 237 238 239 | |