Skip to content

Commit

Permalink
Update documentation for the revision c885267
Browse files Browse the repository at this point in the history
  • Loading branch information
c2c-bot-gis-ci committed Jan 20, 2025
1 parent 0b29161 commit 3d1f87b
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 36 deletions.
4 changes: 2 additions & 2 deletions 2.8/_sources/integrator/create_application.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ We recommend instead that you use dynamic variables as described below.
However, in some use cases extending ``vars.yaml`` may be needed:

* Configuring highly specific environments
* Configuration of a multi-organization project
* Configuration of a multi-tenant project

Use of dynamic variables
........................
Expand Down Expand Up @@ -271,7 +271,7 @@ Do not forget to add your changes to git:

.. note::

If you are using a multi-organization project, you should add all new children to
If you are using a multi-tenant project, you should add all new children to
the parent site check_collector configuration.

After creation and minimal setup the application is ready to be installed.
Expand Down
2 changes: 1 addition & 1 deletion 2.8/_sources/integrator/features.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Features that require additional steps (most of the time):
urllogin
pdfreport
routing
multi_organization
multi_tenant
vector_tiles
extend_application
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _integrator_multi_organization:
.. _integrator_multi_tenant:

Multi organization
==================
Multi-tenant
============

The geoportal can host multiple organizations, with configuration differences for each organization.
In a multi-organization geoportal, each organization will have the same program code
Expand All @@ -11,18 +11,21 @@ In this example we will have the came CSS but we can do some variations by using
see ``cssVars`` in ``gmfOptions`` in the ngeo GMF constants definitions
:ngeo_doc:`gmf constants </jsdoc/module-contribs_gmf_src_options.html>`.

The following lines will provide a basic implementation for multi-organization.
The following lines will provide a basic implementation for multi-tenant.

The code should be adapted, currently it handles the hostnames 'org1.camptocamp.com' and
'org2.camptocamp.com', and you probably want to put the hardcoded values in the config.

``__init__.py``
---------------
``multi_tenant.py``
-------------------

In the file ``geoportal/<package>_geoportal/__init__.py`` add the following lines:
You should have a ``geoportal/<package>_geoportal/multi_tenant.py`` file like this one:

.. code:: python
from pyramid.config import Configurator
def get_instance_prefix(request):
if request.host == "org1.camptocamp.com":
return "org1"
Expand All @@ -49,7 +52,9 @@ In the file ``geoportal/<package>_geoportal/__init__.py`` add the following line
return print_url
# In ``main`` function, after ``config.include("c2cgeoportal_geoportal")``
def includeme(config: Configurator) -> None:
"""Initialize the multi-tenant."""
config.add_request_method(
get_organization_role, name="get_organization_role")
config.add_request_method(
Expand Down Expand Up @@ -107,10 +112,22 @@ Internationalization

For each organization, a set of localization file should be created.

First you should create a ``tenants.yaml`` file like that:

.. code:: yaml
tenants:
org1:
public_url: https://org1.camptocamp.com
suffix: -org1
curl_args: <optional>
org2:
...
The general workflow is:

- The integrator performs ``make update-client-po``.
- This will run one ``update-po`` script for each organization with different environment variables.
- run ``scripts/multi-tenant-update-po``.
- This will run one ``make update-po-from-url`` for each organization with different environment variables.
- The result is one po file set for each organization with the defined suffix.
- The integrator needs to complete the po files with translations.
- When the config Docker image is built, all po files are automatically converted to JSON files
Expand Down
2 changes: 1 addition & 1 deletion 2.8/_sources/integrator/ngeo.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The sub section is the interface name, and after that we have:
``Request.route_url`` `documentation
<https://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.route_url>`_.

* ``lang_urls_suffix`` suffix used in l10n URL, see: :ref:`integrator_multi_organization`.
* ``lang_urls_suffix`` suffix used in l10n URL, see: :ref:`integrator_multi_tenant`.

The dynamic values names are:

Expand Down
4 changes: 2 additions & 2 deletions 2.8/integrator/create_application.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ <h3>Concepts<a class="headerlink" href="#concepts" title="Permalink to this head
However, in some use cases extending <code class="docutils literal notranslate"><span class="pre">vars.yaml</span></code> may be needed:</p>
<ul class="simple">
<li><p>Configuring highly specific environments</p></li>
<li><p>Configuration of a multi-organization project</p></li>
<li><p>Configuration of a multi-tenant project</p></li>
</ul>
</section>
<section id="use-of-dynamic-variables">
Expand Down Expand Up @@ -235,7 +235,7 @@ <h2>Configure the application<a class="headerlink" href="#configure-the-applicat
<span class="prompt1">git<span class="w"> </span>push<span class="w"> </span>origin<span class="w"> </span>master</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you are using a multi-organization project, you should add all new children to
<p>If you are using a multi-tenant project, you should add all new children to
the parent site check_collector configuration.</p>
</div>
<p>After creation and minimal setup the application is ready to be installed.
Expand Down
2 changes: 1 addition & 1 deletion 2.8/integrator/features.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<li class="toctree-l1"><a class="reference internal" href="urllogin.html">URL login</a></li>
<li class="toctree-l1"><a class="reference internal" href="pdfreport.html">PDF Reporting</a></li>
<li class="toctree-l1"><a class="reference internal" href="routing.html">Routing interface</a></li>
<li class="toctree-l1"><a class="reference internal" href="multi_organization.html">Multi organization</a></li>
<li class="toctree-l1"><a class="reference internal" href="multi_tenant.html">Multi-tenant</a></li>
<li class="toctree-l1"><a class="reference internal" href="vector_tiles.html">Vector tiles</a></li>
<li class="toctree-l1"><a class="reference internal" href="extend_application.html">Extend the application</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion 2.8/integrator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<li class="toctree-l2"><a class="reference internal" href="urllogin.html">URL login</a></li>
<li class="toctree-l2"><a class="reference internal" href="pdfreport.html">PDF Reporting</a></li>
<li class="toctree-l2"><a class="reference internal" href="routing.html">Routing interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="multi_organization.html">Multi organization</a></li>
<li class="toctree-l2"><a class="reference internal" href="multi_tenant.html">Multi-tenant</a></li>
<li class="toctree-l2"><a class="reference internal" href="vector_tiles.html">Vector tiles</a></li>
<li class="toctree-l2"><a class="reference internal" href="extend_application.html">Extend the application</a></li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

<title>Multi organization &#8212; c2cgeoportal documentation</title>
<title>Multi-tenant &#8212; c2cgeoportal documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css" />
<link rel="stylesheet" type="text/css" href="../_static/css/c2c.css" />
Expand Down Expand Up @@ -37,21 +37,24 @@

<div class="body" role="main">

<section id="multi-organization">
<span id="integrator-multi-organization"></span><h1>Multi organization<a class="headerlink" href="#multi-organization" title="Permalink to this heading"></a></h1>
<section id="multi-tenant">
<span id="integrator-multi-tenant"></span><h1>Multi-tenant<a class="headerlink" href="#multi-tenant" title="Permalink to this heading"></a></h1>
<p>The geoportal can host multiple organizations, with configuration differences for each organization.
In a multi-organization geoportal, each organization will have the same program code
(Python, Javascript, SCSS). In this mode all the organizations are served by the same infrastructure.</p>
<p>In this example we will have the came CSS but we can do some variations by using CSS var,
see <code class="docutils literal notranslate"><span class="pre">cssVars</span></code> in <code class="docutils literal notranslate"><span class="pre">gmfOptions</span></code> in the ngeo GMF constants definitions
<a class="reference external" href="https://camptocamp.github.io/ngeo/2.8/jsdoc/module-contribs_gmf_src_options.html">gmf constants</a>.</p>
<p>The following lines will provide a basic implementation for multi-organization.</p>
<p>The following lines will provide a basic implementation for multi-tenant.</p>
<p>The code should be adapted, currently it handles the hostnames ‘org1.camptocamp.com’ and
‘org2.camptocamp.com’, and you probably want to put the hardcoded values in the config.</p>
<section id="init-py">
<h2><code class="docutils literal notranslate"><span class="pre">__init__.py</span></code><a class="headerlink" href="#init-py" title="Permalink to this heading"></a></h2>
<p>In the file <code class="docutils literal notranslate"><span class="pre">geoportal/&lt;package&gt;_geoportal/__init__.py</span></code> add the following lines:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">get_instance_prefix</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<section id="multi-tenant-py">
<h2><code class="docutils literal notranslate"><span class="pre">multi_tenant.py</span></code><a class="headerlink" href="#multi-tenant-py" title="Permalink to this heading"></a></h2>
<p>You should have a <code class="docutils literal notranslate"><span class="pre">geoportal/&lt;package&gt;_geoportal/multi_tenant.py</span></code> file like this one:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pyramid.config</span> <span class="kn">import</span> <span class="n">Configurator</span>


<span class="k">def</span> <span class="nf">get_instance_prefix</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">if</span> <span class="n">request</span><span class="o">.</span><span class="n">host</span> <span class="o">==</span> <span class="s2">&quot;org1.camptocamp.com&quot;</span><span class="p">:</span>
<span class="k">return</span> <span class="s2">&quot;org1&quot;</span>
<span class="k">if</span> <span class="n">request</span><span class="o">.</span><span class="n">host</span> <span class="o">==</span> <span class="s2">&quot;org2.camptocamp.com&quot;</span><span class="p">:</span>
Expand All @@ -77,7 +80,9 @@ <h2><code class="docutils literal notranslate"><span class="pre">__init__.py</sp
<span class="k">return</span> <span class="n">print_url</span>


<span class="c1"># In ``main`` function, after ``config.include(&quot;c2cgeoportal_geoportal&quot;)``</span>
<span class="k">def</span> <span class="nf">includeme</span><span class="p">(</span><span class="n">config</span><span class="p">:</span> <span class="n">Configurator</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Initialize the multi-tenant.&quot;&quot;&quot;</span>

<span class="n">config</span><span class="o">.</span><span class="n">add_request_method</span><span class="p">(</span>
<span class="n">get_organization_role</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;get_organization_role&quot;</span><span class="p">)</span>
<span class="n">config</span><span class="o">.</span><span class="n">add_request_method</span><span class="p">(</span>
Expand Down Expand Up @@ -133,10 +138,20 @@ <h2>Roles<a class="headerlink" href="#roles" title="Permalink to this heading">
<section id="internationalization">
<h2>Internationalization<a class="headerlink" href="#internationalization" title="Permalink to this heading"></a></h2>
<p>For each organization, a set of localization file should be created.</p>
<p>First you should create a <code class="docutils literal notranslate"><span class="pre">tenants.yaml</span></code> file like that:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="nt">tenants</span><span class="p">:</span>
<span class="w"> </span><span class="nt">org1</span><span class="p">:</span>
<span class="w"> </span><span class="nt">public_url</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">https://org1.camptocamp.com</span>
<span class="w"> </span><span class="nt">suffix</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">-org1</span>
<span class="w"> </span><span class="nt">curl_args</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">&lt;optional&gt;</span>
<span class="w"> </span><span class="nt">org2</span><span class="p">:</span>
<span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">...</span>
</pre></div>
</div>
<p>The general workflow is:</p>
<ul class="simple">
<li><p>The integrator performs <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">update-client-po</span></code>.</p></li>
<li><p>This will run one <code class="docutils literal notranslate"><span class="pre">update-po</span></code> script for each organization with different environment variables.</p></li>
<li><p>run <code class="docutils literal notranslate"><span class="pre">scripts/multi-tenant-update-po</span></code>.</p></li>
<li><p>This will run one <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">update-po-from-url</span></code> for each organization with different environment variables.</p></li>
<li><p>The result is one po file set for each organization with the defined suffix.</p></li>
<li><p>The integrator needs to complete the po files with translations.</p></li>
<li><p>When the config Docker image is built, all po files are automatically converted to JSON files
Expand Down Expand Up @@ -270,7 +285,7 @@ <h3 id="searchlabel">Quick search</h3>
&amp; <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>

|
<a href="../_sources/integrator/multi_organization.rst.txt"
<a href="../_sources/integrator/multi_tenant.rst.txt"
rel="nofollow">Page source</a>
</div>

Expand Down
2 changes: 1 addition & 1 deletion 2.8/integrator/ngeo.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h2>Dynamic.json view<a class="headerlink" href="#dynamic-json-view" title="Perm
</dd>
</dl>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">lang_urls_suffix</span></code> suffix used in l10n URL, see: <a class="reference internal" href="multi_organization.html#integrator-multi-organization"><span class="std std-ref">Multi organization</span></a>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">lang_urls_suffix</span></code> suffix used in l10n URL, see: <a class="reference internal" href="multi_tenant.html#integrator-multi-tenant"><span class="std std-ref">Multi-tenant</span></a>.</p></li>
</ul>
<p>The dynamic values names are:</p>
<ul class="simple">
Expand Down
4 changes: 2 additions & 2 deletions 2.8/integrator/routing.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<link rel="icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Multi organization" href="multi_organization.html" />
<link rel="next" title="Multi-tenant" href="multi_tenant.html" />
<link rel="prev" title="PDF Reporting" href="pdfreport.html" />

<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
Expand Down Expand Up @@ -162,7 +162,7 @@ <h3>Related Topics</h3>
<li><a href="index.html">Integrator Guide</a><ul>
<li><a href="features.html">Additional features</a><ul>
<li>Previous: <a href="pdfreport.html" title="previous chapter">PDF Reporting</a></li>
<li>Next: <a href="multi_organization.html" title="next chapter">Multi organization</a></li>
<li>Next: <a href="multi_tenant.html" title="next chapter">Multi-tenant</a></li>
</ul></li>
</ul></li>
</ul></li>
Expand Down
4 changes: 2 additions & 2 deletions 2.8/integrator/vector_tiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Extend the application" href="extend_application.html" />
<link rel="prev" title="Multi organization" href="multi_organization.html" />
<link rel="prev" title="Multi-tenant" href="multi_tenant.html" />

<link rel="stylesheet" href="../_static/custom.css" type="text/css" />

Expand Down Expand Up @@ -141,7 +141,7 @@ <h3>Related Topics</h3>
<li><a href="../index.html">Documentation overview</a><ul>
<li><a href="index.html">Integrator Guide</a><ul>
<li><a href="features.html">Additional features</a><ul>
<li>Previous: <a href="multi_organization.html" title="previous chapter">Multi organization</a></li>
<li>Previous: <a href="multi_tenant.html" title="previous chapter">Multi-tenant</a></li>
<li>Next: <a href="extend_application.html" title="next chapter">Extend the application</a></li>
</ul></li>
</ul></li>
Expand Down
Binary file modified 2.8/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion 2.8/searchindex.js

Large diffs are not rendered by default.

0 comments on commit 3d1f87b

Please sign in to comment.