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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Andreas Neumann-4

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 still exists?

What is wrong with my code?

Thanks for any hints!

Andreas



_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Python question: QgsVectorLayer object has no attribute 'pendingFields'

Alessandro Pasotti-2
On Mon, Jan 15, 2018 at 6:10 PM, Andreas Neumann <[hidden email]> wrote:

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 still exists?

What is wrong with my code?

Thanks for any hints!

Andreas


Hi Andreas, I believe you should just use  LayerParcels.fields() pendingFields is gone.


--
Alessandro Pasotti
w3:   www.itopen.it

_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Python question: QgsVectorLayer object has no attribute 'pendingFields'

Etienne Trimaille
In reply to this post by Andreas Neumann-4
pendingFields is gone this morning: https://github.com/qgis/QGIS/pull/6050
Maybe just use `fields()` ?

2018-01-15 20:10 GMT+03:00 Andreas Neumann <[hidden email]>:

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 still exists?

What is wrong with my code?

Thanks for any hints!

Andreas



_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Python question: QgsVectorLayer object has no attribute 'pendingFields'

Andreas Neumann-4

Hi,

oh - thanks, Etienne and Alessandro. If this change is that recent, than it explains why the API doc and the API break document doesn't mention it: https://qgis.org/api/api_break.html

But - aren't we in hard freeze (no more API changes) now since a few days already?

Being confused ....

Andreas

On 2018-01-15 18:14, Etienne Trimaille wrote:

pendingFields is gone this morning: https://github.com/qgis/QGIS/pull/6050
Maybe just use `fields()` ?

2018-01-15 20:10 GMT+03:00 Andreas Neumann <[hidden email]>:

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 still exists?

What is wrong with my code?

Thanks for any hints!

Andreas



_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Python question: QgsVectorLayer object has no attribute 'pendingFields'

Etienne Trimaille
In reply to this post by Etienne Trimaille
While I'm porting my plugin, I'm usually opening this doc

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 <[hidden email]>:
pendingFields is gone this morning: https://github.com/qgis/QGIS/pull/6050
Maybe just use `fields()` ?

2018-01-15 20:10 GMT+03:00 Andreas Neumann <[hidden email]>:

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 still exists?

What is wrong with my code?

Thanks for any hints!

Andreas



_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Python question: QgsVectorLayer object has no attribute 'pendingFields'

Andreas Neumann-4

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

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 <[hidden email]>:
pendingFields is gone this morning: https://github.com/qgis/QGIS/pull/6050
Maybe just use `fields()` ?

2018-01-15 20:10 GMT+03:00 Andreas Neumann <[hidden email]>:

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 still exists?

What is wrong with my code?

Thanks for any hints!

Andreas



_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer




_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Python question: QgsVectorLayer object has no attribute 'pendingFields'

3nids
In reply to this post by Andreas Neumann-4
Hi,


As pointed out, Feature freeze != API freeze.

Many issues are still open here

Best,

Denis

Le lun. 15 janv. 2018 à 13:18, Andreas Neumann <[hidden email]> a écrit :

Hi,

oh - thanks, Etienne and Alessandro. If this change is that recent, than it explains why the API doc and the API break document doesn't mention it: https://qgis.org/api/api_break.html

But - aren't we in hard freeze (no more API changes) now since a few days already?

Being confused ....

Andreas

On 2018-01-15 18:14, Etienne Trimaille wrote:

pendingFields is gone this morning: https://github.com/qgis/QGIS/pull/6050
Maybe just use `fields()` ?

2018-01-15 20:10 GMT+03:00 Andreas Neumann <[hidden email]>:

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 still exists?

What is wrong with my code?

Thanks for any hints!

Andreas



_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer