Fix AttributeError on HTTP/proxy authentications.

This is a regression introduced in cafb487ac9.

Fixes #355.
See #333.
This commit is contained in:
Florian Bruhin 2014-12-17 13:34:40 +01:00
parent a714f0b70c
commit 3cc1134e82

View File

@ -105,15 +105,15 @@ class NetworkManager(QNetworkAccessManager):
self.setCache(cache) self.setCache(cache)
cache.setParent(app) cache.setParent(app)
def _ask(self, win_id, text, mode, owners=()): def _ask(self, win_id, text, mode, owner=None):
"""Ask a blocking question in the statusbar. """Ask a blocking question in the statusbar.
Args: Args:
win_id: The ID of the window which is calling this function. win_id: The ID of the window which is calling this function.
text: The text to display to the user. text: The text to display to the user.
mode: A PromptMode. mode: A PromptMode.
owners: An iterable of objects which will abort the question if owner: An object which will abort the question if destroyed, or
destroyed. None.
Return: Return:
The answer the user gave or None if the prompt was cancelled. The answer the user gave or None if the prompt was cancelled.
@ -122,7 +122,7 @@ class NetworkManager(QNetworkAccessManager):
q.text = text q.text = text
q.mode = mode q.mode = mode
self.shutting_down.connect(q.abort) self.shutting_down.connect(q.abort)
for owner in owners: if owner is not None:
owner.destroyed.connect(q.abort) owner.destroyed.connect(q.abort)
bridge = objreg.get('message-bridge', scope='window', window=win_id) bridge = objreg.get('message-bridge', scope='window', window=win_id)
bridge.ask(q, blocking=True) bridge.ask(q, blocking=True)
@ -163,7 +163,7 @@ class NetworkManager(QNetworkAccessManager):
answer = self._ask(self._win_id, answer = self._ask(self._win_id,
'SSL errors - continue?\n{}'.format(err_string), 'SSL errors - continue?\n{}'.format(err_string),
mode=usertypes.PromptMode.yesno, mode=usertypes.PromptMode.yesno,
owners=(reply,)) owner=reply)
if answer: if answer:
reply.ignoreSslErrors() reply.ignoreSslErrors()
elif ssl_strict: elif ssl_strict:
@ -182,15 +182,14 @@ class NetworkManager(QNetworkAccessManager):
answer = self._ask(self._win_id, answer = self._ask(self._win_id,
"Username ({}):".format(authenticator.realm()), "Username ({}):".format(authenticator.realm()),
mode=usertypes.PromptMode.user_pwd, mode=usertypes.PromptMode.user_pwd,
owners=(reply, authenticator)) owner=reply)
self._fill_authenticator(authenticator, answer) self._fill_authenticator(authenticator, answer)
@pyqtSlot('QNetworkProxy', 'QAuthenticator') @pyqtSlot('QNetworkProxy', 'QAuthenticator')
def on_proxy_authentication_required(self, proxy, authenticator): def on_proxy_authentication_required(self, _proxy, authenticator):
"""Called when a proxy needs authentication.""" """Called when a proxy needs authentication."""
answer = self._ask(self._win_id, "Proxy username ({}):".format( answer = self._ask(self._win_id, "Proxy username ({}):".format(
authenticator.realm()), mode=usertypes.PromptMode.user_pwd, authenticator.realm()), mode=usertypes.PromptMode.user_pwd)
owners=(proxy, authenticator))
self._fill_authenticator(authenticator, answer) self._fill_authenticator(authenticator, answer)
@config.change_filter('general', 'private-browsing') @config.change_filter('general', 'private-browsing')