| Name | feincms3-language-sites JSON |
| Version |
0.3.0
JSON |
| download |
| home_page | None |
| Summary | Multisite support for feincms3 |
| upload_time | 2023-11-01 16:45:18 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.9 |
| license | BSD-3-Clause |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
=======================
feincms3-language-sites
=======================
.. image:: https://github.com/matthiask/feincms3-language-sites/workflows/Tests/badge.svg
:target: https://github.com/matthiask/feincms3-language-sites/
:alt: CI Status
Multisite support for `feincms3 <https://feincms3.readthedocs.io>`_.
Usage scenario
==============
Suppose you have a website with several domains and languages but an exact 1:1
mapping between them. Django offers the ``django.contrib.sites`` application to
partition data but you still have to run one webserver per site.
This app offers a feincms3 abstract page model, a middleware and utilities to
support this scenario. Contrary to `feincms3-sites
<https://github.com/matthiask/feincms3-sites>`__ which is even more flexible
and allows arbitrary combinations of languages and domains this app only allows
exactly one domain per language and exactly one language per domain.
Installation
============
* Install the package using ``pip install feincms3-language-sites`` into an
environment where you're already using feincms3 pages.
* Extend ``feincms3_language_sites.models.AbstractPage`` instead of
``feincms3.pages.AbstractPage``. This abstract page already extends
``feincms3.mixins.LanguageAndTranslationOfMixin`` so you may remove the
language mixins (if you have added them before).
* Replace the ``LocaleMiddleware`` with
``feincms3_language_sites.middleware.site_middleware``. In case you're using
feincms3 applications you should ensure that the ``site_middleware`` is added
before ``feincms3.applications.apps_middleware``.
* Optionally add
``feincms3_language_sites.middleware.redirect_to_site_middleware`` if you
want to enforce the ``host``. The ``SECURE_SSL_REDIRECT`` is also respected.
The ``redirect_to_site_middleware`` has to be added *before* the
``SecurityMiddleware`` otherwise users may get redirected twice in a row.
* Configure the sites.
Configuration
=============
Possible configuration:
.. code-block:: python
SITES = {
"de": {
"host": "127.0.0.1:8000",
"host_re": r"example\.com$|127.0.0.1:8000$",
},
"fr": {
"host": "localhost:8000",
},
}
Sites are checked in the order they are declared (since dictionaries are
guaranteed to preserve the ordering of keys since Python 3.7).
The keys of the ``SITES`` dictionary have to be equal to all language codes in
``LANGUAGES``. The ``host`` is required and should only consist of the host and
an optional port, nothing else. If ``host_re`` is given the
``request.get_host()`` return value is matched against the ``host_re`` regular
expression, otherwise the ``host`` has to match exactly.
The ``site_middleware`` automatically raises a ``DisallowedHost`` exception if
no site matches the current request (which produces the same error as Django if
the request doesn't match ``ALLOWED_HOSTS``).
Utilities
=========
* ``feincms3_language_sites.models.site_for_host``
* ``feincms3_language_sites.models.reverse_language_site_app``
* ``feincms3_language_sites.templatetags.feincms3_language_sites.site_translations``
Notes
=====
Note that ``Page.objects.active()`` only returns pages in the current language.
If you want to generate translation links (e.g. using ``...|translations`` in a
template) you do not want to use the ``.active()`` queryset method but build
something yourself which runs ``.filter(is_active=True)``.
Raw data
{
"_id": null,
"home_page": null,
"name": "feincms3-language-sites",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Matthias Kestenholz <mk@feinheit.ch>",
"download_url": "https://files.pythonhosted.org/packages/d0/82/b7ca274b038701757db391032074d336a47cb88c15bea9f0ddf939cce9b6/feincms3_language_sites-0.3.0.tar.gz",
"platform": null,
"description": "=======================\nfeincms3-language-sites\n=======================\n\n.. image:: https://github.com/matthiask/feincms3-language-sites/workflows/Tests/badge.svg\n :target: https://github.com/matthiask/feincms3-language-sites/\n :alt: CI Status\n\nMultisite support for `feincms3 <https://feincms3.readthedocs.io>`_.\n\n\nUsage scenario\n==============\n\nSuppose you have a website with several domains and languages but an exact 1:1\nmapping between them. Django offers the ``django.contrib.sites`` application to\npartition data but you still have to run one webserver per site.\n\nThis app offers a feincms3 abstract page model, a middleware and utilities to\nsupport this scenario. Contrary to `feincms3-sites\n<https://github.com/matthiask/feincms3-sites>`__ which is even more flexible\nand allows arbitrary combinations of languages and domains this app only allows\nexactly one domain per language and exactly one language per domain.\n\n\nInstallation\n============\n\n* Install the package using ``pip install feincms3-language-sites`` into an\n environment where you're already using feincms3 pages.\n* Extend ``feincms3_language_sites.models.AbstractPage`` instead of\n ``feincms3.pages.AbstractPage``. This abstract page already extends\n ``feincms3.mixins.LanguageAndTranslationOfMixin`` so you may remove the\n language mixins (if you have added them before).\n* Replace the ``LocaleMiddleware`` with\n ``feincms3_language_sites.middleware.site_middleware``. In case you're using\n feincms3 applications you should ensure that the ``site_middleware`` is added\n before ``feincms3.applications.apps_middleware``.\n* Optionally add\n ``feincms3_language_sites.middleware.redirect_to_site_middleware`` if you\n want to enforce the ``host``. The ``SECURE_SSL_REDIRECT`` is also respected.\n The ``redirect_to_site_middleware`` has to be added *before* the\n ``SecurityMiddleware`` otherwise users may get redirected twice in a row.\n* Configure the sites.\n\n\nConfiguration\n=============\n\nPossible configuration:\n\n.. code-block:: python\n\n SITES = {\n \"de\": {\n \"host\": \"127.0.0.1:8000\",\n \"host_re\": r\"example\\.com$|127.0.0.1:8000$\",\n },\n \"fr\": {\n \"host\": \"localhost:8000\",\n },\n }\n\nSites are checked in the order they are declared (since dictionaries are\nguaranteed to preserve the ordering of keys since Python 3.7).\n\nThe keys of the ``SITES`` dictionary have to be equal to all language codes in\n``LANGUAGES``. The ``host`` is required and should only consist of the host and\nan optional port, nothing else. If ``host_re`` is given the\n``request.get_host()`` return value is matched against the ``host_re`` regular\nexpression, otherwise the ``host`` has to match exactly.\n\nThe ``site_middleware`` automatically raises a ``DisallowedHost`` exception if\nno site matches the current request (which produces the same error as Django if\nthe request doesn't match ``ALLOWED_HOSTS``).\n\n\nUtilities\n=========\n\n* ``feincms3_language_sites.models.site_for_host``\n* ``feincms3_language_sites.models.reverse_language_site_app``\n* ``feincms3_language_sites.templatetags.feincms3_language_sites.site_translations``\n\n\nNotes\n=====\n\nNote that ``Page.objects.active()`` only returns pages in the current language.\nIf you want to generate translation links (e.g. using ``...|translations`` in a\ntemplate) you do not want to use the ``.active()`` queryset method but build\nsomething yourself which runs ``.filter(is_active=True)``.\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "Multisite support for feincms3",
"version": "0.3.0",
"project_urls": {
"Homepage": "https://github.com/matthiask/feincms3-language-sites/"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "743ad9e8bfb0c1b2939bfbc403e3fb745fe659f08d4bae2f84e4189b4cd00834",
"md5": "ea73c9a03c5d31d60ae0497cb983fea7",
"sha256": "e3396bb04cd92ebe257c297b0e277a7e9658cdb92ceee0c65da057c99e58c929"
},
"downloads": -1,
"filename": "feincms3_language_sites-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ea73c9a03c5d31d60ae0497cb983fea7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9683,
"upload_time": "2023-11-01T16:45:19",
"upload_time_iso_8601": "2023-11-01T16:45:19.761702Z",
"url": "https://files.pythonhosted.org/packages/74/3a/d9e8bfb0c1b2939bfbc403e3fb745fe659f08d4bae2f84e4189b4cd00834/feincms3_language_sites-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d082b7ca274b038701757db391032074d336a47cb88c15bea9f0ddf939cce9b6",
"md5": "a33193bff22ba854b78653ee3a1d6f5d",
"sha256": "9321ee906a04fa43fa267f25b5e59dfe675f8c3db4895ecb2b3de33edb65b784"
},
"downloads": -1,
"filename": "feincms3_language_sites-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "a33193bff22ba854b78653ee3a1d6f5d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 14646,
"upload_time": "2023-11-01T16:45:18",
"upload_time_iso_8601": "2023-11-01T16:45:18.339778Z",
"url": "https://files.pythonhosted.org/packages/d0/82/b7ca274b038701757db391032074d336a47cb88c15bea9f0ddf939cce9b6/feincms3_language_sites-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-01 16:45:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "matthiask",
"github_project": "feincms3-language-sites",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "feincms3-language-sites"
}