In PyQGIS, how can I get the number of features that have been created in a given layer and that are pending to be saved in the layer when "Toggle editing" or "Saving layer edits"?
Say that you have a vector layer referenced:
lyr = iface.activeLayer()
At this point, I assume you start an edit session and digitize some features.
Now you can use the
QgsVectorLayerEditBuffer class, in this way:
if lyr.editBuffer(): print len( lyr.editBuffer().addedFeatures() ), "features to add!"
addedFeatures gives you a dictionary of new features that are pending. As you're interested in the count, you can use