Skip to content

Commit

Permalink
[Server] Defined QGIS_SERVER_APPLICATION_NAME variable
Browse files Browse the repository at this point in the history
The QGIS_SERVER_APPLICATION_NAME variable can be used instead of QGIS_APPLICATION_FULL_NAME.
  • Loading branch information
rldhont committed Jan 16, 2023
1 parent 5deca63 commit bcd3feb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions python/server/auto_generated/qgsserversettings.sip.in
Expand Up @@ -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,
};
};

Expand Down Expand Up @@ -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 );
Expand Down
15 changes: 15 additions & 0 deletions src/server/qgsserversettings.cpp
Expand Up @@ -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()
Expand Down Expand Up @@ -694,3 +704,8 @@ QStringList QgsServerSettings::allowedExtraSqlTokens() const
}
return strVal.split( ',' );
}

QString QgsServerSettings::applicationName() const
{
return value( QgsServerSettingsEnv::QGIS_SERVER_APPLICATION_NAME ).toString().trimmed();
}
11 changes: 11 additions & 0 deletions src/server/qgsserversettings.h
Expand Up @@ -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 )
};
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bcd3feb

Please sign in to comment.