Personally I'm not a fan of that.
Why don't we make startEditing() return a edit buffer/edit session. So you
could do this:
session = layer.editSession()
session.addFeature(feature)
...
session.commitChanges()
This would mean that everyone can keep their own edit buffers and can do
what they want. Means you could also doing this:
with layer.editSession() as session:
session.addFeature(...)
which will commit the features at the end.
- Nathan
On Tue, Apr 16, 2013 at 4:10 PM, Martin Dobias <[email protected]> wrote:
> On Tue, Apr 16, 2013 at 12:53 AM, Nathan Woodrow <[email protected]>
> wrote:
> > What would be the API calls in order to add a new feature to a layer and
> > commit the result?
>
> layer.startEditing()
> layer.editBuffer().addFeature( feature )
> layer.commitChanges()
>
> Anyway if someone wants to add a new feature permanently, it should be
> rather done this way:
> layer.dataProvider().addFeatures( [feature] )
> It's more efficient and it does not mess with the editing state of the
> layer (imagine you are editing a layer and a plugin action will commit
> all your changes without asking!).
>
> Martin
>
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer