[Server] Defined QGIS_SERVER_APPLICATION_NAME variable

The QGIS_SERVER_APPLICATION_NAME variable can be used instead of QGIS_APPLICATION_FULL_NAME.
This commit is contained in:
rldhont 2023-01-13 16:45:04 +01:00
parent 5deca63412
commit bcd3febef8
3 changed files with 37 additions and 0 deletions

View File

@ -63,6 +63,7 @@ Provides some enum describing the environment currently supported for configurat
QGIS_SERVER_PROJECT_CACHE_CHECK_INTERVAL,
QGIS_SERVER_PROJECT_CACHE_STRATEGY,
QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS,
QGIS_SERVER_APPLICATION_NAME,
};
};
@ -339,6 +340,16 @@ The default value is an empty string, the value can be changed by setting the en
variable QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS.
.. versionadded:: 3.28
%End
QString applicationName() const;
%Docstring
Returns the QGIS Server application name.
The default value is the concatenation of :py:func:`QgsApplication.applicationName()`
and :py:func:`QgsApplication.platform()` separated by a space, the value can be changed
by setting the environment variable QGIS_SERVER_APPLICATION_NAME.
.. versionadded:: 3.30
%End
static QString name( QgsServerSettingsEnv::EnvVar env );

View File

@ -379,6 +379,16 @@ void QgsServerSettings::initSettings()
};
mSettings[ sAllowedExtraSqlTokens.envVar ] = sAllowedExtraSqlTokens;
const Setting sApplicationName = { QgsServerSettingsEnv::QGIS_SERVER_APPLICATION_NAME,
QgsServerSettingsEnv::DEFAULT_VALUE,
QStringLiteral( "The QGIS Server application name" ),
QStringLiteral( "/qgis/application_full_name" ),
QVariant::String,
QVariant( QgsApplication::applicationFullName() ),
QVariant()
};
mSettings[ sApplicationName.envVar ] = sApplicationName;
}
void QgsServerSettings::load()
@ -694,3 +704,8 @@ QStringList QgsServerSettings::allowedExtraSqlTokens() const
}
return strVal.split( ',' );
}
QString QgsServerSettings::applicationName() const
{
return value( QgsServerSettingsEnv::QGIS_SERVER_APPLICATION_NAME ).toString().trimmed();
}

View File

@ -81,6 +81,7 @@ class SERVER_EXPORT QgsServerSettingsEnv : public QObject
QGIS_SERVER_PROJECT_CACHE_CHECK_INTERVAL, //! Set the interval for cache invalidation strategy 'interval', default to 0 which select the legacy File system watcher (since QGIS 3.26).
QGIS_SERVER_PROJECT_CACHE_STRATEGY, //! Set the project cache strategy. Possible values are 'filesystem', 'periodic' or 'off' (since QGIS 3.26).
QGIS_SERVER_ALLOWED_EXTRA_SQL_TOKENS, //! Adds these tokens to the list of allowed tokens that the services accept when filtering features (since QGIS 3.28).
QGIS_SERVER_APPLICATION_NAME, //! Define the QGIS Server application name (since QGIS 3.30).
};
Q_ENUM( EnvVar )
};
@ -339,6 +340,16 @@ class SERVER_EXPORT QgsServerSettings
*/
QStringList allowedExtraSqlTokens() const;
/**
* 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.
*
* \since QGIS 3.30
*/
QString applicationName() const;
/**
* Returns the string representation of a setting.
* \since QGIS 3.16