From 2bd320695504c7862f357da94eb5878e292b1d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Thu, 29 Aug 2019 17:39:57 +0200 Subject: [PATCH] Be able to have dynamic geo_table --- doc/integrator/database.rst | 15 ++++++++++++--- geoportal/c2cgeoportal_geoportal/views/layers.py | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/integrator/database.rst b/doc/integrator/database.rst index 36986cf7e01..5898da78b96 100644 --- a/doc/integrator/database.rst +++ b/doc/integrator/database.rst @@ -42,11 +42,12 @@ Prepare the project To be able to proceed like this, the variables ``PGSCHEMA`` and the ``DOCKER_PGSCHEMA_STATIC`` should be managed in your makefiles: -* the ``PGSCHEMA`` variable should be set in the ``Makefile``, in this example, it will be set to ``main_2019``. -* the ``DOCKER_PGSCHEMA_STATIC`` variable for production should be set in a specific makefile +* The ``PGSCHEMA`` variable should be set in the ``Makefile``, in this example, it will be set to + ``main_2019``. +* The ``DOCKER_PGSCHEMA_STATIC`` variable for production should be set in a specific makefile for production e.-g. ``production.mk``, it will be set for example to ``integration_static`` in the Makefile, and to ``production_static`` in the production makefile. -* the line ``PGSCHEMA=${docker_schema}`` should be removed from your ``.env.mako`` file. +* The line ``PGSCHEMA=${docker_schema}`` should be removed from your ``.env.mako`` file. Start a new version @@ -110,3 +111,11 @@ Publish the new version on production: now, integration and production both use For OpenShift projects, just push the integration branch into the production branch. The schema ``main_2019`` still exists, so if needed, the production can be rolled back to this content. + + +Editing +~~~~~~~ + +To have a differant schema for the geodata used in the editing we can defined the geo_table like +``{GEODATA_SCHEMA}.table`` where ``{GEODATA_SCHEMA}`` will be replaced by the ``GEODATA_SCHEMA`` +environment variable. diff --git a/geoportal/c2cgeoportal_geoportal/views/layers.py b/geoportal/c2cgeoportal_geoportal/views/layers.py index d349a451eeb..1e5af173667 100644 --- a/geoportal/c2cgeoportal_geoportal/views/layers.py +++ b/geoportal/c2cgeoportal_geoportal/views/layers.py @@ -27,6 +27,7 @@ # of the authors and should not be interpreted as representing official policies, # either expressed or implied, of the FreeBSD Project. +import os from datetime import datetime from pyramid.httpexceptions import HTTPInternalServerError, \ @@ -498,7 +499,7 @@ def get_layer_class(layer, with_last_update_columns=False): primary_key = Layers.get_metadata(layer, "geotablePrimaryKey") cls = get_class( - str(layer.geo_table), + str(layer.geo_table.format(os.environ)), exclude_properties=exclude, primary_key=primary_key, attributes_order=attributes_order,