[QGIS-Developer] Python question: QgsVectorLayer object has no attribute 'pendingFields'

Andreas Neumann a.neumann at carto.net
Mon Jan 15 09:31:52 PST 2018


Thanks - that's a good hint!

Andreas


On 15.01.2018 18:20, Etienne Trimaille wrote:
> While I'm porting my plugin, I'm usually opening this doc
> https://github.com/qgis/QGIS/blob/master/doc/api_break.dox
>
> Then I search for every new exception I have, I often find a solution 
> there.
>
> 2018-01-15 20:14 GMT+03:00 Etienne Trimaille 
> <etienne.trimaille at gmail.com <mailto:etienne.trimaille at gmail.com>>:
>
>     pendingFields is gone this morning:
>     https://github.com/qgis/QGIS/pull/6050
>     <https://github.com/qgis/QGIS/pull/6050>
>     Maybe just use `fields()` ?
>
>     2018-01-15 20:10 GMT+03:00 Andreas Neumann <a.neumann at carto.net
>     <mailto:a.neumann at carto.net>>:
>
>         Hi,
>
>         I am trying to fix some Python code that worked before, but
>         not anymore due to API changes in master meanwhile.
>
>         I am getting a reference to a layer by name and then want to
>         query the 'pendingFields'. Here is the code I use:
>
>         ---------------------
>
>         LayerParcels=
>         QgsProject.instance().layerStore().mapLayersByName('Parcels')[0]
>
>         newParcel = QgsFeature()
>
>         newParcel .setFields(LayerParcels.pendingFields())
>
>         -------------------------
>
>         The first two lines seem to work, but the third line triggers
>         an error:
>
>         AttributeError: 'QgsVectorLayer' object has no attribute
>         'pendingFields'
>
>         Why is that?
>
>         This code worked a few weeks before and the 'pendingFields' -
>         according to https://qgis.org/api/classQgsVectorLayer.html
>         <https://qgis.org/api/classQgsVectorLayer.html> still exists?
>
>         What is wrong with my code?
>
>         Thanks for any hints!
>
>         Andreas
>
>
>
>         _______________________________________________
>         QGIS-Developer mailing list
>         QGIS-Developer at lists.osgeo.org
>         <mailto:QGIS-Developer at lists.osgeo.org>
>         List info:
>         https://lists.osgeo.org/mailman/listinfo/qgis-developer
>         <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
>         Unsubscribe:
>         https://lists.osgeo.org/mailman/listinfo/qgis-developer
>         <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180115/ee3f9a93/attachment.html>


More information about the QGIS-Developer mailing list