common
common
This module contains common logic, shared beyond all specialized parts of the QGIS-Server-Light interface.
BBox
dataclass
Bases: BaseInterface
Source code in src/qgis_server_light/interface/common.py
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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
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
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
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
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
to_2d_list() -> list
Source code in src/qgis_server_light/interface/common.py
186 187 | |
to_2d_string() -> str
Source code in src/qgis_server_light/interface/common.py
189 190 | |
to_list() -> list
Source code in src/qgis_server_light/interface/common.py
180 181 | |
to_string() -> str
Source code in src/qgis_server_light/interface/common.py
183 184 | |
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
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 | |
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
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
PgServiceConf
dataclass
Bases: BaseInterface
A typed definition of the pg_service.conf definition which might be used.
Source code in src/qgis_server_light/interface/common.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
application_name: str | None = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
client_encoding: str = field(default='UTF8', metadata={'type': 'Element'})
class-attribute
instance-attribute
dbname: str | None = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
host: str | None = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
name: str = field(metadata={'type': 'Element'})
class-attribute
instance-attribute
password: str | None = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
port: int | None = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
redacted_fields: set
property
service: str | None = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
sslmode: SslMode = field(default=(SslMode.PREFER), metadata={'type': 'Element'})
class-attribute
instance-attribute
user: str | None = field(default=None, metadata={'type': 'Element'})
class-attribute
instance-attribute
__init__(name: str, host: str | None = None, port: int | None = None, user: str | None = None, dbname: str | None = None, password: str | None = None, sslmode: SslMode = SslMode.PREFER, application_name: str | None = None, client_encoding: str = 'UTF8', service: str | None = None) -> 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
103 104 105 106 107 108 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 | |
__format__(format_spec)
Source code in src/qgis_server_light/interface/common.py
119 120 | |
__init__(value, redacted_text='**REDACTED**')
Source code in src/qgis_server_light/interface/common.py
109 110 111 | |
__json__()
Source code in src/qgis_server_light/interface/common.py
122 123 | |
__repr__()
Source code in src/qgis_server_light/interface/common.py
116 117 | |
__str__()
Source code in src/qgis_server_light/interface/common.py
113 114 | |
reveal()
Allows access to the original value when necessary.
Returns:
-
–
The secret string.
Source code in src/qgis_server_light/interface/common.py
125 126 127 128 129 130 131 132 133 | |
SslMode
Bases: str, Enum
Source code in src/qgis_server_light/interface/common.py
136 137 138 139 140 141 142 | |
ALLOW = 'allow'
class-attribute
instance-attribute
DISABLE = 'disable'
class-attribute
instance-attribute
PREFER = 'prefer'
class-attribute
instance-attribute
REQUIRE = 'require'
class-attribute
instance-attribute
VERIFY_CA = 'verify-ca'
class-attribute
instance-attribute
VERIFY_FULL = 'verify-full'
class-attribute
instance-attribute
Style
dataclass
Bases: BaseInterface
Source code in src/qgis_server_light/interface/common.py
246 247 248 249 250 251 252 253 | |