From e7555e02d25df999547a7cf7e361b290c3254ed6 Mon Sep 17 00:00:00 2001
From: Wannes Rombouts <wapiflapi@yahoo.fr>
Date: Wed, 31 Jul 2013 09:55:07 +0200
Subject: [PATCH] Fixed connection string for PG db when not going through
 gedal.

---
 src/mapfile.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mapfile.py b/src/mapfile.py
index 75f7d1a..b363a85 100644
--- a/src/mapfile.py
+++ b/src/mapfile.py
@@ -161,11 +161,11 @@ class Layer(MetadataMixin):
         ms_template_layer = self.ms.clone()
         ms_template_layer.name = sld_layer_name
         mf.ms.insertLayer(ms_template_layer)
-              
+
         try:
             ms_template_layer.applySLD(new_sld, sld_layer_name)
         except:
-            raise ValueError("Unable to access storage.")     
+            raise ValueError("Unable to access storage.")
 
         for i in xrange(ms_template_layer.numclasses):
             ms_class = ms_template_layer.getClass(i)
@@ -333,7 +333,9 @@ class FeatureTypeModel(LayerModel):
         cparam = info["connectionParameters"]
         if cparam.get("dbtype", None) in ["postgis", "postgres", "postgresql"]:
             self.ms.connectiontype = mapscript.MS_POSTGIS
-            self.ms.connection = get_store_connection_string(info)
+            connection = "dbname=%s port=%s host=%s " % (cparam["database"], cparam["port"], cparam["host"])
+            connection += " ".join("%s=%s" % (p, cparam[p]) for p in ["user", "password"] if p in cparam)
+            self.ms.connection = connection
             self.ms.data = "%s FROM %s" % (ds[ft_name].get_geometry_column(), ft_name)
             self.set_metadata("ows_extent", "%s %s %s %s" %
                 (ft.get_extent().minX(), ft.get_extent().minY(),
-- 
GitLab