diff --git a/geo/Geoserver.py b/geo/Geoserver.py index e4c60db..5476c13 100644 --- a/geo/Geoserver.py +++ b/geo/Geoserver.py @@ -1948,7 +1948,15 @@ def publish_featurestore_sqlview( if workspace is None: workspace = "default" - layer_xml = """{0} + # issue #87 + if key_column is not None: + key_column_xml = """{}""".format(key_column) + + else: + key_column_xml = """""" + + layer_xml = """ + {0} true {4} @@ -1965,20 +1973,14 @@ def publish_featurestore_sqlview( {2} {3} {5} - + {6} - """.format( - name, sql, geom_name, geom_type, workspace, srid + + """.format( + name, sql, geom_name, geom_type, workspace, srid, key_column_xml ) - # issue #87 - if key_column is not None: - layer_xml += """{}""".format(key_column) - - # final xml structure to post - layer_xml_post = """{}""".format(layer_xml) - # rest API url url = "{}/rest/workspaces/{}/datastores/{}/featuretypes".format( self.service_url, workspace, store_name @@ -1990,7 +1992,7 @@ def publish_featurestore_sqlview( # request r = requests.post( url, - data=layer_xml_post, + data=layer_xml, auth=(self.username, self.password), headers=headers, )