[QGIS-Developer] pyqgis - layer.saveDefaultStyle() for PostGIS layers
Jorge Gustavo Pereira Bastos Rocha
jgr at di.uminho.pt
Mon Sep 25 06:50:40 PDT 2017
Hi,
It already happened to me. The first user to save a style became the owner of the table. No other users were able to write on the layer_style table, because there were DEFAULT PRIVILEGES defined.
Can you check the postgrsql log to see if there is any problem related with permissions?
Regards,
Jorge Gustavo
________________________________________
De: QGIS-Developer [qgis-developer-bounces at lists.osgeo.org] em nome de kimaidou [kimaidou at gmail.com]
Enviado: 25 de Setembro de 2017 14:23
Para: Luigi Pirelli
Cc: qgis-developer at lists.osgeo.org
Assunto: Re: [QGIS-Developer] pyqgis - layer.saveDefaultStyle() for PostGIS layers
Hi,
@ Tom : I really would like to trust QGIS method instead of managing manually different providers.
@ Luigi
No error message, even worse : i got a message telling everything went well ;)
layer.saveDefaultStyle()
(u'The style dbname=\'qgis\' host=localhost port=5432 user=\'mdouchin\' sslmode=disable key=\'ogc_fid\' estimatedmetadata=true srid=2154 type=MultiPolygon table="sup"."geo_commune" (geom) sql= was updated in the database.', True)
But the line is not created in the layer_styles table.
Michaƫl
2017-09-25 14:48 GMT+02:00 Luigi Pirelli <luipir at gmail.com<mailto:luipir at gmail.com>>:
from the code:
mLayer->saveStyleToDatabase and mLayer->saveDefaultStyle
and in
QString QgsMapLayer::saveDefaultStyle( bool & theResultFlag )
{
return saveNamedStyle( styleURI(), theResultFlag );
}
=> seems you are doing correct.
any log message?
******************************************
void QgsVectorLayerProperties::saveDefaultStyle_clicked()
{
apply();
QString errorMsg;
if ( mLayer->dataProvider()->isSaveAndLoadStyleToDBSupported() )
{
QMessageBox askToUser;
askToUser.setText( tr( "Save default style to: " ) );
askToUser.setIcon( QMessageBox::Question );
askToUser.addButton( tr( "Cancel" ), QMessageBox::RejectRole );
askToUser.addButton( tr( "Local database" ), QMessageBox::NoRole );
askToUser.addButton( tr( "Datasource database" ), QMessageBox::YesRole );
switch ( askToUser.exec() )
{
case 0:
return;
case 2:
mLayer->saveStyleToDatabase( "", "", true, "", errorMsg );
if ( errorMsg.isNull() )
{
return;
}
break;
default:
break;
}
}
bool defaultSavedFlag = false;
errorMsg = mLayer->saveDefaultStyle( defaultSavedFlag );
if ( !defaultSavedFlag )
{
QMessageBox::warning( this, tr( "Default Style" ), errorMsg );
}
}
Luigi Pirelli
**************************************************************************************************
* Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS 2nd Edition:
* https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
**************************************************************************************************
On 25 September 2017 at 13:44, Tom Chadwin <tom.chadwin at nnpa.org.uk<mailto:tom.chadwin at nnpa.org.uk>> wrote:
> Perhaps you have to do it manually via a PostGIS query matching
> f_table_catalog, f_table_schema, and f_table_name, and updating styleqml and
> stylesld?
>
> Tom
>
>
>
> -----
> Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org<mailto:QGIS-Developer at lists.osgeo.org>
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
More information about the QGIS-Developer
mailing list