I have problems with the vector layer rollback and commitChanges function, it doesn't matter wich one i call the vector layer is is Changed.Here is my code i hope someone can help me. This is my firt post and im new with qgis.
from qgis.core import QgsApplication,QgsVectorLayer,QgsVectorDataProvider from PyQt4.QtCore import QVariant
if name == "main":
QgsApplication.setPrefixPath('/usr', True)
QgsApplication.initQgis()
vLayer = QgsVectorLayer(
"/home/diademuertos/scripts/qgis/data/point.shp",
"vLayerTest",
"ogr")
vLayer.startEditing()
caps = vLayer.dataProvider().capabilities()
if caps & QgsVectorDataProvider.ChangeAttributeValues:
attrs = { 0: QVariant(2),1: QVariant("B"),2:QVariant("Dont!!!")}
vLayer.dataProvider().changeAttributeValues({ 1 : attrs })
else:
print "OOPS"
r = False
if r:
print "commitChanges"
vLayer.commitChanges()
else:
print "rollback"
vLayer.rollBack()
QgsApplication.exitQgis()