Skip to content
Permalink
Browse files

make DbManager aware of the new authentication system

  • Loading branch information
SebDieBln authored and luipir committed Nov 16, 2015
1 parent ee093b2 commit 93ab8900337bb538a308f6a083fee0f74912e340
@@ -38,10 +38,10 @@ def __del__(self):
self.connection = None

def uri(self):
return QgsDataSourceURI(self._uri.uri())
return QgsDataSourceURI(self._uri.uri(False))

def publicUri(self):
publicUri = QgsDataSourceURI.removePassword(self._uri.uri())
publicUri = QgsDataSourceURI.removePassword(self._uri.uri(False))
return QgsDataSourceURI(publicUri)

def hasSpatialSupport(self):
@@ -207,7 +207,7 @@ def toSqlLayer(self, sql, geomCol, uniqueCol,
if avoidSelectById:
uri.disableSelectAtId(True)
provider = self.dbplugin().providerName()
vlayer = QgsVectorLayer(uri.uri(), layerName, provider)
vlayer = QgsVectorLayer(uri.uri(False), layerName, provider)

# handling undetermined geometry type
if not vlayer.isValid():
@@ -217,7 +217,7 @@ def toSqlLayer(self, sql, geomCol, uniqueCol,
uri.setWkbType(wkbType)
if srid:
uri.setSrid(unicode(srid))
vlayer = QgsVectorLayer(uri.uri(), layerName, provider)
vlayer = QgsVectorLayer(uri.uri(False), layerName, provider)

return vlayer

@@ -279,8 +279,8 @@ def toSqlLayer(self, sql, geomCol, uniqueCol, layerName="QueryLayer", layerType=
uri.disableSelectAtId(True)
provider = self.dbplugin().providerName()
if layerType == QgsMapLayer.RasterLayer:
return QgsRasterLayer(uri.uri(), layerName, provider)
return QgsVectorLayer(uri.uri(), layerName, provider)
return QgsRasterLayer(uri.uri(False), layerName, provider)
return QgsVectorLayer(uri.uri(False), layerName, provider)

def registerAllActions(self, mainWindow):
self.registerDatabaseActions(mainWindow)
@@ -668,13 +668,13 @@ def uri(self):

def mimeUri(self):
layerType = "raster" if self.type == Table.RasterType else "vector"
return u"%s:%s:%s:%s" % (layerType, self.database().dbplugin().providerName(), self.name, self.uri().uri())
return u"%s:%s:%s:%s" % (layerType, self.database().dbplugin().providerName(), self.name, self.uri().uri(False))

def toMapLayer(self):
from qgis.core import QgsVectorLayer, QgsRasterLayer

provider = self.database().dbplugin().providerName()
uri = self.uri().uri()
uri = self.uri().uri(False)
if self.type == Table.RasterType:
return QgsRasterLayer(uri, self.name, provider)
return QgsVectorLayer(uri, self.name, provider)
@@ -79,18 +79,18 @@ def connect(self, parent=None):

uri = QgsDataSourceURI()

settingsList = ["service", "host", "port", "database", "username", "password"]
service, host, port, database, username, password = map(lambda x: settings.value(x, "", type=str), settingsList)
settingsList = ["service", "host", "port", "database", "username", "password", "authcfg"]
service, host, port, database, username, password, authcfg = map(lambda x: settings.value(x, "", type=str), settingsList)

useEstimatedMetadata = settings.value("estimatedMetadata", False, type=bool)
sslmode = settings.value("sslmode", QgsDataSourceURI.SSLprefer, type=int)

settings.endGroup()

if service:
uri.setConnection(service, database, username, password, sslmode)
uri.setConnection(service, database, username, password, sslmode, authcfg)
else:
uri.setConnection(host, port, database, username, password, sslmode)
uri.setConnection(host, port, database, username, password, sslmode, authcfg)

uri.setUseEstimatedMetadata(useEstimatedMetadata)

@@ -113,7 +113,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'face', 'mbr', '', 'face_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBPolygon)
layer = QgsVectorLayer(uri.uri(), u'%s.face_mbr' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.face_mbr' % toponame, provider)
layer.loadNamedStyle(os.path.join(template_dir, 'face_mbr.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
@@ -127,7 +127,7 @@ def run(item, action, mainwindow):
uri.setDataSource('', u'(%s\n)' % sql, 'geom', '', 'face_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBPolygon)
layer = QgsVectorLayer(uri.uri(), u'%s.face' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.face' % toponame, provider)
layer.setExtent(face_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'face.qml'))
registry.addMapLayers([layer])
@@ -141,7 +141,7 @@ def run(item, action, mainwindow):
uri.setDataSource('', u'(%s)' % sql, 'geom', '', 'face_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBPoint)
layer = QgsVectorLayer(uri.uri(), u'%s.face_seed' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.face_seed' % toponame, provider)
layer.setExtent(face_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'face_seed.qml'))
registry.addMapLayers([layer])
@@ -158,7 +158,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'node', 'geom', '', 'node_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBPoint)
layer = QgsVectorLayer(uri.uri(), u'%s.node' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.node' % toponame, provider)
layer.loadNamedStyle(os.path.join(template_dir, 'node.qml'))
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
@@ -170,7 +170,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'node', 'geom', '', 'node_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBPoint)
layer = QgsVectorLayer(uri.uri(), u'%s.node_id' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.node_id' % toponame, provider)
layer.setExtent(node_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'node_label.qml'))
registry.addMapLayers([layer])
@@ -185,7 +185,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBLineString)
layer = QgsVectorLayer(uri.uri(), u'%s.edge' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.edge' % toponame, provider)
registry.addMapLayers([layer])
legend.moveLayer(layer, group)
legend.setLayerVisible(layer, False)
@@ -196,7 +196,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBLineString)
layer = QgsVectorLayer(uri.uri(), u'%s.directed_edge' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.directed_edge' % toponame, provider)
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'edge.qml'))
registry.addMapLayers([layer])
@@ -208,7 +208,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBLineString)
layer = QgsVectorLayer(uri.uri(), u'%s.edge_id' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.edge_id' % toponame, provider)
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'edge_label.qml'))
registry.addMapLayers([layer])
@@ -220,7 +220,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBLineString)
layer = QgsVectorLayer(uri.uri(), u'%s.face_left' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.face_left' % toponame, provider)
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'face_left.qml'))
registry.addMapLayers([layer])
@@ -232,7 +232,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBLineString)
layer = QgsVectorLayer(uri.uri(), u'%s.face_right' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.face_right' % toponame, provider)
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'face_right.qml'))
registry.addMapLayers([layer])
@@ -244,7 +244,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBLineString)
layer = QgsVectorLayer(uri.uri(), u'%s.next_left' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.next_left' % toponame, provider)
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'next_left.qml'))
registry.addMapLayers([layer])
@@ -256,7 +256,7 @@ def run(item, action, mainwindow):
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBLineString)
layer = QgsVectorLayer(uri.uri(), u'%s.next_right' % toponame, provider)
layer = QgsVectorLayer(uri.uri(False), u'%s.next_right' % toponame, provider)
layer.setExtent(edge_extent)
layer.loadNamedStyle(os.path.join(template_dir, 'next_right.qml'))
registry.addMapLayers([layer])
@@ -105,7 +105,7 @@ def _loadTablePreview(self, table, limit=False):
uri.setDataSource("", u"(SELECT * FROM %s LIMIT 1000)" % table.quotedName(), table.geomColumn, "",
uniqueField.name)
provider = table.database().dbplugin().providerName()
vl = QgsVectorLayer(uri.uri(), table.name, provider)
vl = QgsVectorLayer(uri.uri(False), table.name, provider)
else:
vl = table.toMapLayer()

0 comments on commit 93ab890

Please sign in to comment.
You can’t perform that action at this time.