Skip to content
Permalink
Browse files
QgsCredentials: fix sip bindings
dbmanager: QgsCredentials is in core (fixes #8345)
  • Loading branch information
jef-n committed Jul 22, 2013
1 parent 5d32231 commit aa7c428775b35aa4e08dbb2445cbd4953fd7d381
Showing with 6 additions and 13 deletions.
  1. +1 −1 python/core/qgscredentials.sip
  2. +5 −12 python/plugins/db_manager/db_plugins/postgis/plugin.py
@@ -8,7 +8,7 @@ class QgsCredentials
//! virtual destructor
virtual ~QgsCredentials();

bool get( QString realm, QString &username, QString &password, QString message = QString::null );
bool get( QString realm, QString &username /In,Out/, QString &password /In,Out/, QString message = QString::null );
void put( QString realm, QString username, QString password );

//! retrieves instance
@@ -34,6 +34,8 @@

from ..html_elems import HtmlParagraph, HtmlList, HtmlTable

from qgis.core import QgsCredentials


def classFactory():
return PostGisDBPlugin
@@ -98,19 +100,10 @@ def connect(self, parent=None):
except ConnectionError, e:
err = str(e)

hasCredentialDlg = True
try:
from qgis.gui import QgsCredentials
except ImportError: # no credential dialog
hasCredentialDlg = False

# ask for valid credentials
max_attempts = 3
for i in range(max_attempts):
if hasCredentialDlg:
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)
else:
(password, ok) = QInputDialog.getText(parent, self.tr("Enter password"), self.tr('Enter password for connection "%s":') % conn_name, QLineEdit.Password)
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)

if not ok:
return False
@@ -128,8 +121,8 @@ def connect(self, parent=None):
err = str(e)
continue

if hasCredentialDlg:
QgsCredentials.instance().put(uri.connectionInfo(), username, password)
QgsCredentials.instance().put(uri.connectionInfo(), username, password)

return True

return False

0 comments on commit aa7c428

Please sign in to comment.