Skip to content

Commit

Permalink
without the double star, the formating inject all the environment
Browse files Browse the repository at this point in the history
variables as a gigantic string and the code fail wonderfully.

export TOTO=foobar
python

>>> import os
>>> print('{TOTO}'.format(**os.environ))
foobar
  • Loading branch information
ochriste committed Jan 6, 2020
1 parent 6b375d3 commit 47e0abc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions doc/administrator/editing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ a string of the form ``[<schemaname>.]<tablename>``. If ``schemaname`` is
omitted, the table is assumed to be in the ``public`` schema. The label
corresponding to this field is *Related Postgres table* in the admin interface.

The ``geoTable`` field support named formatting and can get values from the
environment variables, for example:

``[<schemaname>_{some-named-variable}.]<tablename>``

with "some-named-variable" defined in the environment.

Support for other database sessions has also been implemented:

``[<database-session-name>.[<schemaname>.]]<tablename>``

See :doc:`../integrator/multiple_databases.html`.

.. warning::

Only layers embedded in a layergroup are detected as editable.
Expand Down
2 changes: 1 addition & 1 deletion geoportal/c2cgeoportal_geoportal/views/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,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.format(os.environ)),
str(layer.geo_table.format(**os.environ)),
exclude_properties=exclude,
primary_key=primary_key,
attributes_order=attributes_order,
Expand Down

0 comments on commit 47e0abc

Please sign in to comment.