[QGIS-Developer] FeatureIterator is constructed but not iterated when creating a custom QgsVectorDataProvider in Python

Mats Taraldsvik mats.taraldsvik at gmail.com
Fri Nov 20 05:22:23 PST 2020


Hi,

I'm trying to create/prototype a custom QgsVectorDataProvider in Python to
retrieve data from a HTTP REST API.

When testing, I do the following to register my provider:

from qgis.core import QgsProviderRegistry, QgsProviderMetadata
from provider import MyProvider
registry = QgsProviderRegistry.instance()
metadata = QgsProviderMetadata(MyProvider.providerKey(),
MyProvider.description(),
MyProvider.createProvider)
registry.registerProvider(metadata)
layer = QgsVectorLayer(<my-url>, 'Test myprovider', 'myprovider-plugin')
QgsProject.instance().addMapLayer(layer)
This seems to initialize the provider, although it stops after the
constructor of MyFeatureIterator(QgsAbstractFeatureIterator) is run.
For this test, data is retrieved from the REST API in the constructor, and
I can see in the logs that the data is retrieved.

I expected it to start iterating objects, but the next message in the log
is prepareSimplification (I have added a log message to every class method
to watch progress in the logs), then nothing.

I even installed qgis-dev and watched the logs using Microsoft's
DebugViewer, but I could not see any relevant information.

Could someone please help me or tell me where to look to solve this issue
and start iterating with nextFeature/fetchFeature? Regards,
Mats Taraldsvik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20201120/9382e6f6/attachment.html>


More information about the QGIS-Developer mailing list