[QGIS-trac] [Quantum GIS] #1462: PostGIS layer loaded via Python is not saved correct in qgs project file

Quantum GIS qgis at qgis.org
Mon Dec 15 05:39:12 EST 2008


#1462: PostGIS layer loaded via Python is not saved correct in qgs project file
---------------------------------------------------------+------------------
   Reporter:  hdus                                       |              Owner:  jef          
       Type:  bug                                        |             Status:  new          
   Priority:  critical: causes crash or data corruption  |          Milestone:  Version 1.0.0
  Component:  Project Loading / Saving                   |            Version:  HEAD         
   Keywords:                                             |   Platform_version:               
   Platform:  All                                        |           Must_fix:  No           
Status_info:  0                                          |  
---------------------------------------------------------+------------------
 I load a PostGIS layer via Python with:
 {{{
 ...
 uri = QgsDataSourceURI()
 uri.setConnection(self.DBHOST, self.DBPORT, self.DBNAME, self.DBUSER,
 self.DBPASSWD)
 uri.setDataSource(str(schema), str(table), "wkb_geometry", "archive=0")
 vlayer = QgsVectorLayer(uri.uri(), layerName, "postgres")
 QgsMapLayerRegistry.instance().addMapLayer(vlayer)
 ...
 }}}

 The layer is added to mapcanvas and it is displayed correct. Save the
 project to testpython.qgs and reload this project-file QGIS reports:
 Unable to load layer.

 Load the same layer with the postgis connector. Save the project to
 testconnector.qgs and reload this project-file everthing works fine.

 I compare the two project files and I see a relevant difference, the
 following tags are missing in testpython.qgs:

 {{{
             <edittypes>
                 <edittype type="0" name="archive" />
                 <edittype type="0" name="archive_date" />
                 <edittype type="0" name="gem_bfs" />
                 <edittype type="0" name="new_date" />
                 <edittype type="0" name="nummer" />
                 <edittype type="0" name="ogc_fid" />
             </edittypes>
             <displayfield>ogc_fid</displayfield>
             <label>0</label>
             <attributeactions/>
             <singlesymbol>
                 <symbol>
                     <lowervalue></lowervalue>
                     <uppervalue></uppervalue>
                     <label></label>
                     <pointsymbol>hard:circle</pointsymbol>
                     <pointsize>2</pointsize>
 <rotationclassificationfieldname></rotationclassificationfieldname>
 <scaleclassificationfieldname></scaleclassificationfieldname>
                     <outlinecolor red="0" blue="0" green="0" />
                     <outlinestyle>SolidLine</outlinestyle>
                     <outlinewidth>0.26</outlinewidth>
                     <fillcolor red="153" blue="60" green="213" />
                     <fillpattern>SolidPattern</fillpattern>
                     <texturepath></texturepath>
                 </symbol>
             </singlesymbol>
             <labelattributes>
                 <label fieldname="" text="Label" />
                 <family fieldname="" name="Sans Serif" />
                 <size fieldname="" units="pt" value="12" />
                 <bold fieldname="" on="0" />
                 <italic fieldname="" on="0" />
                 <underline fieldname="" on="0" />
                 <color fieldname="" red="0" blue="0" green="0" />
                 <x fieldname="" />
                 <y fieldname="" />
                 <offset x="0" y="0" units="pt" yfieldname="" xfieldname=""
 />
                 <angle fieldname="" value="0" auto="0" />
                 <alignment fieldname="" value="center" />
                 <buffercolor fieldname="" red="255" blue="255" green="255"
 />
                 <buffersize fieldname="" units="pt" value="1" />
                 <bufferenabled fieldname="" on="" />
                 <multilineenabled fieldname="" on="" />
             </labelattributes>
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/1462>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list