[Qgis-developer] beforeCommitChanges signal : equivalent to SQL BEFORE triggers' OLD and NEW values

Olivier Dalang olivier.dalang at gmail.com
Tue Jun 23 04:04:08 PDT 2015


Hi,

In SQL, using triggers, it's possible to pre-process values before
inserting/deleting/updating them. That's a very powerful feature for things
such as validation, formatting, logging modifications, timestamping,
caching, synchronization across table/databases, running other scripts, etc.

Is it possible to emulate this in QGIS with Python (so purely on client
side) ?
There is the QgsVectorLayer beforeCommitChanges signal, which is triggered
exactly at the correct time, but I didn't find a way to iterate through the
modified features, getting their OLD and NEW state.

I think it may be possible to implement it using the attributeValueChanged
(QgsFeatureId fid, int idx, const QVariant) and the geometryChanged
(QgsFeatureId fid, QgsGeometry geom) signals to store a list of NEW states,
and then make a new query to the data provider to get the OLD states (using
QgsVectorDataProvider getFeatures).

Would that work ? It's a bit sad that there's a new query to make to the
provider. The best would be to have the attributeValueChanged and the
geometryChanged signals to return the OLD value as well directly. Would
this be a reasonable feature request ?

Or is there another way to achieve the same result that I didn't think of ?

Thanks a lot,

Olivier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150623/fe3fa3d6/attachment-0001.html>


More information about the Qgis-developer mailing list