Skip to content

Commit aa7c428

Browse files
committedJul 22, 2013
QgsCredentials: fix sip bindings
dbmanager: QgsCredentials is in core (fixes #8345)
1 parent 5d32231 commit aa7c428

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed
 

‎python/core/qgscredentials.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class QgsCredentials
88
//! virtual destructor
99
virtual ~QgsCredentials();
1010

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

1414
//! retrieves instance

‎python/plugins/db_manager/db_plugins/postgis/plugin.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
from ..html_elems import HtmlParagraph, HtmlList, HtmlTable
3636

37+
from qgis.core import QgsCredentials
38+
3739

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

101-
hasCredentialDlg = True
102-
try:
103-
from qgis.gui import QgsCredentials
104-
except ImportError: # no credential dialog
105-
hasCredentialDlg = False
106-
107103
# ask for valid credentials
108104
max_attempts = 3
109105
for i in range(max_attempts):
110-
if hasCredentialDlg:
111-
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)
112-
else:
113-
(password, ok) = QInputDialog.getText(parent, self.tr("Enter password"), self.tr('Enter password for connection "%s":') % conn_name, QLineEdit.Password)
106+
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)
114107

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

131-
if hasCredentialDlg:
132-
QgsCredentials.instance().put(uri.connectionInfo(), username, password)
124+
QgsCredentials.instance().put(uri.connectionInfo(), username, password)
125+
133126
return True
134127

135128
return False

0 commit comments

Comments
 (0)
Please sign in to comment.