[Qgis-developer] Remove editing functions from QgsVectorLayer

Nathan Woodrow madmanwoo at gmail.com
Tue Apr 16 02:26:52 PDT 2013


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 <wonder.sk at gmail.com> wrote:

> On Tue, Apr 16, 2013 at 12:53 AM, Nathan Woodrow <madmanwoo at gmail.com>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130416/3d34b065/attachment.html>


More information about the Qgis-developer mailing list