qgis / QGIS-Enhancement-Proposals

QEP's (QGIS Enhancement Proposals) are used in the process of creating and discussing new enhancements for QGIS
117 stars 37 forks source link

Make core QgsNetworkAccessManager more user/python friendly #123

Open rduivenvoorde opened 6 years ago

rduivenvoorde commented 6 years ago

QGIS Enhancement: Title

Date 2018/04/19

Author Richard Duivenvoorde (@rduivenvoorde)

Contact richard@duif.net

maintainer @user

Version QGIS 3.x

Summary

Currently developers (both py and cpp) can use QgsNetworkAccessManager to do their network related actions:

https://qgis.org/api/classQgsNetworkAccessManager.html

It is a very thin wrapper around QtNetworkAccessManager

http://doc.qt.io/qt-5/qnetworkaccessmanager.html

If I'm correct, the Qgs-version adds:

Python plugin developers, often use other Network related libraries to do requests to webservices (modules like http2, requests etc). Thereby often 'forgetting' about proxies and QGIS-own authentication framework.

Alessandro/Boundless for QGIS2 introduced a Python NetworkAccessManager, mimicking the http2 api:

https://github.com/boundlessgeo/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py

While this module mostly works in QGIS3 too, I think it is nicer to actually add some of these utility methods to core QgsNetworkAccessManager class.

In this way it is natively available for Python developers, and they do not have to depend on external libraries. It also brings (hopefully) the right way of threading to a larger audience (https://github.com/qgis/QGIS-Enhancement-Proposals/issues/122#issuecomment-382983640)

Proposed Solution

Some nice to have things:

Example(s)

See for example: http://docs.python-requests.org/en/master/

And the boundless NAM https://github.com/boundlessgeo/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py

Performance Implications

None

Backwards Compatibility

(required)

Votes

(required)

luipir commented 6 years ago

@rduivenvoorde may you explain "have api for handling the QgsAuthenticationManager (maybe even a way for handling/showing the authentication dialogs?)"

rduivenvoorde commented 6 years ago

@luipir I was thinking about showing the widgets (if not set yet), like asking for a master password, or just asking for a password. Though that probably should not be the responsibiliy of QgsNetworkAccessManager