Class: QgsServerSettings

class qgis.server.QgsServerSettings

Bases: sip.wrapper

Provides a way to retrieve settings by prioritizing according to environment variables, ini file and default values.

QgsServerSettings() Constructor.

QgsServerSettings(QgsServerSettings)

Methods

allowedExtraSqlTokens

Returns the list of strings that represent the allowed extra SQL tokens accepted as components of a feature filter.

apiResourcesDirectory

Returns the server-wide base directory where HTML templates and static assets (e.g. images, js and css files) are searched for.

apiWfs3MaxLimit

Returns the server-wide maximum allowed value for "limit" in a features request.

applicationName

Returns the QGIS Server application name.

cacheDirectory

Returns the cache directory.

cacheSize

Returns the cache size.

capabilitiesCacheSize

Returns the maximum number of project capabilities to cache.

forceReadOnlyLayers

Returns True if the reading flag force layer read only is activated.

getPrintDisabled

Returns True if WMS GetPrint request is disabled and the project's reading flag QgsProject.ReadFlag.FlagDontLoadLayouts is activated.

ignoreBadLayers

Returns True if the bad layers are ignored and False when the presence of a bad layers invalidates the whole project making it unavailable.

iniFile

Returns the ini file loaded by QSetting.

landingPageBaseUrlPrefix

Returns the landing page base URL regular expression, defaults to /.

landingPageProjectsDirectories

Returns the directories used by the landing page service to find .qgs and .qgz projects.

landingPageProjectsPgConnections

Returns the PostgreSQL connection strings used by the landing page service to find projects.

load

Load settings according to current environment variables.

logFile

Returns the log file.

logLevel

Returns the log level.

logProfile

Returns True if profile information has to be added to the logs, default value is False.

logStderr

Returns whether logging to stderr is activated.

logSummary

Log a summary of settings currently loaded.

maxThreads

Returns the maximum number of threads to use.

name

Returns the string representation of a setting.

overrideSystemLocale

Overrides system locale

parallelRendering

Returns parallel rendering setting.

projectCacheCheckInterval

Returns the config cache check interval (in ms) for the 'periodic' strategy.

projectCacheStrategy

Returns the project's cache strategy The default value is 'filesystem', the value can be changed by setting the environment variable QGIS_SERVER_PROJECT_CACHE_STRATEGY.

projectFile

Returns the QGS project file to use.

serviceUrl

Returns the service URL from the setting.

showGroupSeparator

Show group (thousand) separator

trustLayerMetadata

Returns True if the reading flag trust layer metadata is activated.

wmsMaxHeight

Returns the server-wide max height of a WMS GetMap request.

wmsMaxWidth

Returns the server-wide max width of a WMS GetMap request.

allowedExtraSqlTokens(self) List[str]

Returns the list of strings that represent the allowed extra SQL tokens accepted as components of a feature filter. The default value is an empty string, the value can be changed by setting the environment variable QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS.

New in version 3.28.

Return type:

List[str]

apiResourcesDirectory(self) str

Returns the server-wide base directory where HTML templates and static assets (e.g. images, js and css files) are searched for.

The default path is calculated by joining QgsApplication.pkgDataPath() with “resources/server/api”, this path can be changed by setting the environment variable QGIS_SERVER_API_RESOURCES_DIRECTORY.

New in version 3.10.

Return type:

str

apiWfs3MaxLimit(self) int

Returns the server-wide maximum allowed value for "limit" in a features request.

The default value is 10000, this value can be changed by setting the environment variable QGIS_SERVER_API_WFS3_MAX_LIMIT.

New in version 3.10.

Return type:

int

applicationName(self) str

Returns the QGIS Server application name. The default value is the concatenation of QgsApplication.applicationName() and QgsApplication.platform() separated by a space, the value can be changed by setting the environment variable QGIS_SERVER_APPLICATION_NAME.

New in version 3.30.

Return type:

str

cacheDirectory(self) str

Returns the cache directory.

Return type:

str

Returns:

the directory.

cacheSize(self) int

Returns the cache size.

Return type:

int

Returns:

the cache size.

capabilitiesCacheSize(self) int

Returns the maximum number of project capabilities to cache. The default value is 40 and the value can be changed by setting the environment variable QGIS_SERVER_CAPABILITIES_CACHE_SIZE.

New in version 3.31.

Return type:

int

forceReadOnlyLayers(self) bool

Returns True if the reading flag force layer read only is activated.

The default value is False, this value can be changed by setting the environment variable QGIS_SERVER_FORCE_READONLY_LAYERS.

New in version 3.28.

Return type:

bool

getPrintDisabled(self) bool

Returns True if WMS GetPrint request is disabled and the project’s reading flag QgsProject.ReadFlag.FlagDontLoadLayouts is activated.

The default value is False, this value can be changed by setting the environment variable QGIS_SERVER_DISABLE_GETPRINT.

New in version 3.16.

Return type:

bool

ignoreBadLayers(self) bool

Returns True if the bad layers are ignored and False when the presence of a bad layers invalidates the whole project making it unavailable.

The default value is True, this value can be changed by setting the environment variable QGIS_SERVER_IGNORE_BAD_LAYERS.

New in version 3.10.5.

Return type:

bool

iniFile(self) str

Returns the ini file loaded by QSetting.

Return type:

str

Returns:

the path of the ini file or an empty string if none is loaded.

landingPageBaseUrlPrefix(self) str

Returns the landing page base URL regular expression, defaults to /.

New in version 3.20.

Return type:

str

landingPageProjectsDirectories(self) str

Returns the directories used by the landing page service to find .qgs and .qgz projects. Multiple directories can be specified by separating them with ‘||’.

New in version 3.16.

Return type:

str

landingPageProjectsPgConnections(self) str

Returns the PostgreSQL connection strings used by the landing page service to find projects. Multiple connections can be specified by separating them with ‘||’.

New in version 3.16.

Return type:

str

load(self)

Load settings according to current environment variables.

load(self, envVarName: str) -> bool Load setting for a specific environment variable name.

Returns:

True if loading is successful, False in case of an invalid name.

logFile(self) str

Returns the log file.

Return type:

str

Returns:

the path of the log file or an empty string if none is defined.

logLevel(self) Qgis.MessageLevel

Returns the log level.

Return type:

Qgis.MessageLevel

Returns:

the log level.

logProfile(self) bool

Returns True if profile information has to be added to the logs, default value is False.

Note

this flag is only effective when logLevel() returns Qgis.MessageLevel.Info (0)

See also

logLevel()

New in version 3.18.

Return type:

bool

logStderr(self) bool

Returns whether logging to stderr is activated.

Return type:

bool

Returns:

True if logging to stderr is activated, False otherwise.

New in version 3.4.

logSummary(self)

Log a summary of settings currently loaded.

maxThreads(self) int

Returns the maximum number of threads to use.

Return type:

int

Returns:

the number of threads.

name(env: QgsServerSettingsEnv.EnvVar) str

Returns the string representation of a setting.

New in version 3.16.

Parameters:

env (QgsServerSettingsEnv.EnvVar) –

Return type:

str

overrideSystemLocale(self) str

Overrides system locale

Return type:

str

Returns:

the optional override for system locale.

New in version 3.8.

parallelRendering(self) bool

Returns parallel rendering setting.

Return type:

bool

Returns:

True if parallel rendering is activated, False otherwise.

projectCacheCheckInterval(self) int

Returns the config cache check interval (in ms) for the ‘periodic’ strategy.

New in version 3.26.

Return type:

int

projectCacheStrategy(self) str

Returns the project’s cache strategy The default value is ‘filesystem’, the value can be changed by setting the environment variable QGIS_SERVER_PROJECT_CACHE_STRATEGY. Possible values are:

  • ‘filesystem’: Use file system watcher for notifying projects change. Note that it works only with projects stored in files and not across mounted NFS volumes on Linux.

  • ‘periodic’: Timer based periodic check for project’s changes. Works with all storage backend.

  • ‘off’: Disable completely internal project’s cache handling

New in version 3.26.

Return type:

str

projectFile(self) str

Returns the QGS project file to use.

Return type:

str

Returns:

the path of the QGS project or an empty string if none is defined.

serviceUrl(self, service: str) str

Returns the service URL from the setting.

New in version 3.20.

Parameters:

service (str) –

Return type:

str

showGroupSeparator(self) bool

Show group (thousand) separator

Return type:

bool

Returns:

if group separator must be shown, default to False.

New in version 3.8.

trustLayerMetadata(self) bool

Returns True if the reading flag trust layer metadata is activated.

The default value is False, this value can be changed by setting the environment variable QGIS_SERVER_TRUST_LAYER_METADATA.

New in version 3.16.

Return type:

bool

wmsMaxHeight(self) int

Returns the server-wide max height of a WMS GetMap request. The lower one of this and the project configuration is used.

Return type:

int

Returns:

the max height of a WMS GetMap request.

New in version 3.6.2.

wmsMaxWidth(self) int

Returns the server-wide max width of a WMS GetMap request. The lower one of this and the project configuration is used.

Return type:

int

Returns:

the max width of a WMS GetMap request.

New in version 3.6.2.