<div dir="ltr"><div>Hi,</div><div><br></div><div>Yes, thank you - your example along with <a href="https://github.com/blazek/django-provider/blob/master/djangoprovider/provider.py">https://github.com/blazek/django-provider/blob/master/djangoprovider/provider.py</a> is in fact what I am using to write my dataprovider.</div><div><br></div><div>I must have overlooked something, since the results are never iterated, but the logs are not helpful at all, unfortunately... :(</div><div><br></div><div>There must be a reason why there is no attempt to iterate..?<br></div><div><br></div><div>Mats<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 20, 2020 at 2:30 PM Alessandro Pasotti <<a href="mailto:apasotti@gmail.com">apasotti@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, Nov 20, 2020 at 2:22 PM Mats Taraldsvik<br>
<<a href="mailto:mats.taraldsvik@gmail.com" target="_blank">mats.taraldsvik@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I'm trying to create/prototype a custom QgsVectorDataProvider in Python to retrieve data from a HTTP REST API.<br>
><br>
> When testing, I do the following to register my provider:<br>
><br>
> from qgis.core import QgsProviderRegistry, QgsProviderMetadata<br>
> from provider import MyProvider<br>
> registry = QgsProviderRegistry.instance()<br>
> metadata = QgsProviderMetadata(MyProvider.providerKey(), MyProvider.description(), MyProvider.createProvider)<br>
> registry.registerProvider(metadata)<br>
> layer = QgsVectorLayer(<my-url>, 'Test myprovider', 'myprovider-plugin')<br>
> QgsProject.instance().addMapLayer(layer)<br>
> This seems to initialize the provider, although it stops after the constructor of MyFeatureIterator(QgsAbstractFeatureIterator) is run.<br>
> 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.<br>
><br>
> 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.<br>
><br>
> I even installed qgis-dev and watched the logs using Microsoft's DebugViewer, but I could not see any relevant information.<br>
><br>
> Could someone please help me or tell me where to look to solve this issue and start iterating with nextFeature/fetchFeature? Regards,<br>
<br>
<br>
AFAIK there is only one example I wrote for testing purposes ages ago:<br>
<a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/provider_python.py" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS/blob/master/tests/src/python/provider_python.py</a><br>
<br>
I'm not sure it will be useful but it's a start.<br>
<br>
Kind regards.<br>
<br>
-- <br>
Alessandro Pasotti<br>
QCooperative:  <a href="http://www.qcooperative.net" rel="noreferrer" target="_blank">www.qcooperative.net</a><br>
ItOpen:   <a href="http://www.itopen.it" rel="noreferrer" target="_blank">www.itopen.it</a><br>
</blockquote></div>