This is a general question. I'm stepping through the pyqgis code and the layer isValid() is always False. I don't see any error messages showing any reason why it wouldn't load. Other similars have loaded without problems.
Just trying to see if I need to actually download the QGIS source and start stepping through that as well...? (i hope not)
the first layer loads without problems. it's referencing a postgis table. the second doesn't but the another_table is a view. perhaps that makes a difference but there are no error messages or exceptions letting me know what's wrong...
#first vLayer self.uri.setDataSource('public','some_table','location','') self.first_layer = QgsVectorLayer(self.uri.uri(), 'Some Locations', "postgres") QgsMapLayerRegistry.instance().addMapLayer( self.first_layer) #second Layer self.uri.setDataSource('public', 'another_table', 'location','') self.second_layer = QgsVectorLayer(self.uri.uri(), 'Another set of Locations', "postgres") QgsMapLayerRegistry.instance().addMapLayer( self.second_layer)