Skip to content
Permalink
Browse files

Add name method

  • Loading branch information
pblottiere committed Aug 27, 2020
1 parent 32f9b35 commit 904000c1438e5f8c6eeef73cd233b6540d4d10cb
@@ -214,13 +214,19 @@ variable QGIS_SERVER_TRUST_LAYER_METADATA.
.. versionadded:: 3.16
%End

<<<<<<< HEAD
bool getPrintDisabled() const;
%Docstring
Returns ``True`` if WMS GetPrint request is disabled and the project's
reading flag DONT_LOAD_LAYOUTS is activated.

The default value is ``False``, this value can be changed by setting the environment
variable QGIS_SERVER_DISABLE_GETPRINT.
=======
static QString name( QgsServerSettingsEnv::EnvVar env );
%Docstring
Returns the string representation of a setting.
>>>>>>> 63c64d45a6... Add name method

.. versionadded:: 3.16
%End
@@ -316,8 +316,7 @@ QVariant QgsServerSettings::value( QgsServerSettingsEnv::EnvVar envVar, bool act
{
if ( actual )
{
const QMetaEnum metaEnum( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
const QString envValue( getenv( metaEnum.valueToKey( envVar ) ) );
const QString envValue( getenv( name( envVar ).toStdString().c_str() ) );

if ( ! envValue.isEmpty() )
return envValue;
@@ -382,16 +381,21 @@ void QgsServerSettings::prioritize( const QMap<QgsServerSettingsEnv::EnvVar, QSt
}
}

QString QgsServerSettings::name( QgsServerSettingsEnv::EnvVar env )
{
const QMetaEnum metaEnumEnv( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );
return metaEnumEnv.valueToKey( env );
}

void QgsServerSettings::logSummary() const
{
const QMetaEnum metaEnumSrc( QMetaEnum::fromType<QgsServerSettingsEnv::Source>() );
const QMetaEnum metaEnumEnv( QMetaEnum::fromType<QgsServerSettingsEnv::EnvVar>() );

QgsMessageLog::logMessage( "QGIS Server Settings: ", "Server", Qgis::Info );
for ( Setting s : mSettings )
{
const QString src = metaEnumSrc.valueToKey( s.src );
const QString var = metaEnumEnv.valueToKey( s.envVar );
const QString var = name( s.envVar );

const QString msg = " - " + var + " / '" + s.iniKey + "' (" + s.descr + "): '" + value( s.envVar ).toString() + "' (read from " + src + ")";
QgsMessageLog::logMessage( msg, "Server", Qgis::Info );
@@ -275,6 +275,12 @@ class SERVER_EXPORT QgsServerSettings
*/
bool getPrintDisabled() const;

/*
* Returns the string representation of a setting.
* \since QGIS 3.16
*/
static QString name( QgsServerSettingsEnv::EnvVar env );

private:
void initSettings();
QVariant value( QgsServerSettingsEnv::EnvVar envVar, bool actual = false ) const;
@@ -75,6 +75,7 @@ QMap<QString, QString> QgsLandingPageUtils::projects( const QgsServerSettings &s
}

// Scan QGIS_SERVER_PROJECTS_DIRECTORIES
const QString envDirName = QgsServerSettings::name( QgsServerSettingsEnv::QGIS_SERVER_LANDING_PAGE_PROJECTS_DIRECTORIES );
if ( AVAILABLE_PROJECTS.isEmpty() )
{
const auto cProjectDirs { projectDir.split( QStringLiteral( "||" ) ) };
@@ -101,17 +102,18 @@ QMap<QString, QString> QgsLandingPageUtils::projects( const QgsServerSettings &s
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "QGIS_SERVER_PROJECTS_DIRECTORIES entry '%1' was not found: skipping." ).arg( path ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
QgsMessageLog::logMessage( QStringLiteral( "%1 entry '%2' was not found: skipping." ).arg( envDirName ).arg( path ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
}
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "QGIS_SERVER_PROJECTS_DIRECTORIES empty path: skipping." ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
QgsMessageLog::logMessage( QStringLiteral( "%1 empty path: skipping." ).arg( envDirName ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
}
}
}

// PG projects (there is no watcher for PG: scan every time)
const QString envPgName = QgsServerSettings::name( QgsServerSettingsEnv::QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS );
const auto storage { QgsApplication::instance()->projectStorageRegistry()->projectStorageFromType( QStringLiteral( "postgresql" ) ) };
Q_ASSERT( storage );
const auto cPgConnections { pgConnections.split( QStringLiteral( "||" ) ) };
@@ -132,12 +134,12 @@ QMap<QString, QString> QgsLandingPageUtils::projects( const QgsServerSettings &s
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "QGIS_SERVER_PROJECTS_PG_CONNECTIONS entry '%1' was not found or has not projects: skipping." ).arg( connectionString ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
QgsMessageLog::logMessage( QStringLiteral( "%1 entry '%2' was not found or has not projects: skipping." ).arg( envPgName ).arg( connectionString ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
}
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "QGIS_SERVER_PROJECTS_PG_CONNECTIONS empty connection: skipping." ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
QgsMessageLog::logMessage( QStringLiteral( "%1 empty connection: skipping." ).arg( envPgName ), QStringLiteral( "Landing Page" ), Qgis::MessageLevel::Warning );
}
}

0 comments on commit 904000c

Please sign in to comment.
You can’t perform that action at this time.