edx-django-sites-extensions


Nameedx-django-sites-extensions JSON
Version 4.2.0 PyPI version JSON
download
home_pagehttps://github.com/openedx/edx-django-sites-extensions
SummaryCustom extensions for the Django sites framework
upload_time2024-04-18 15:26:13
maintainerNone
docs_urlNone
authoredX
requires_pythonNone
licenseAGPL
keywords django sites edx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            Part of `edX code <http://code.edx.org/>`_.

edx-django-sites-extensions  |CI|_ |Codecov|_
=================================================
.. |CI| image:: https://github.com/openedx/edx-django-sites-extensions/workflows/Python%20CI/badge.svg?branch=master
.. _CI: https://github.com/openedx/edx-django-sites-extensions/actions?query=workflow%3A%22Python+CI%22

.. |Codecov| image:: http://codecov.io/github/edx/edx-django-sites-extensions/coverage.svg?branch=master
.. _Codecov: http://codecov.io/github/edx/edx-django-sites-extensions?branch=master


This package includes extensions to the Django "sites" framework
used by Open edX Django IDAs (independently deployable applications).

Overview
--------

In order to support multitenancy in an IDA, it is helpful to make use of
the `Django "sites" framework <https://docs.djangoproject.com/en/1.9/ref/contrib/sites/>`_.

One shortcoming of the Django "sites" framework is the fact that the CurrentSiteMiddleware
provided by the framework that adds the current site to incoming requests does not allow
you to fall back to a site that you can configure in settings in case the current site
cannot be determined from the host of the incoming request.

The Django app provided by this package overcomes this issue by monkey patching the
django.contrib.sites.models.SiteManager.get_current() function which is called by the
CurrentSiteMiddleware to determine the current site. The patched version of this function
will first try to determine the current site by checking the host of the incoming request
and attempting to match a site by domain. If a site cannot be found this way, it will fall
back to the default site configured by setting the SITE_ID setting.

Another issue with the Django "sites" framework is that it uses an in-memory cache of Site
models which makes it difficult to update models associated with the Site model via Django
admin and have those updates be reflected across all Python processes in a multi-process
application environment.

Again the Django app provided by this package monkey patches the private SiteManager query
functions that implement the in-memory caching mechanism to add a configurable timeout to
the Site cache allowing model updates to be reflected across all processes after the specified
timeout.

To enable this functionality in your Django project:

Install this package in your python environment
    ::

    $ pip install edx-django-sites-extensions

Add :code:`django.contrib.sites.middleware.CurrentSiteMiddleware` to your :code:`MIDDLEWARE_CLASSES` list.

Set the :code:`SITE_ID` setting::

    SITE_ID = 1

This package also provides a mechanism for settings up URL redirects for your application.
It makes use of the Django redirects app and provides middleware which will check for
Redirect models whose old_path field matches the path of the incoming request and redirects
those requests to the new_path of the Redirect model.

To enable this functionality in your Django project:

Install this package in your python environment
    ::

        $ pip install edx-django-sites-extensions

Add :code:`django_sites_extensions.middleware.RedirectMiddleware` to your :code:`MIDDLEWARE_CLASSES` list.

You can then use Django admin to create Redirect models.

Documentation
-------------

The docs for edx-django-sites-extensions are on Read the Docs:  https://edx-django-sites-extensions.readthedocs.org.

License
-------

The code in this repository is licensed under LICENSE_TYPE unless
otherwise noted.

Please see ``LICENSE.txt`` for details.

How To Contribute
-----------------

Contributions are very welcome.

Please read `How To Contribute <https://github.com/openedx/.github/blob/master/CONTRIBUTING.md>`_ for details.


Reporting Security Issues
-------------------------

Please do not report security issues in public. Please email security@openedx.org.

Mailing List and IRC Channel
----------------------------

You can discuss this code in the `edx-code Google Group <https://groups.google.com/forum/#!forum/edx-code>`_.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/openedx/edx-django-sites-extensions",
    "name": "edx-django-sites-extensions",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "Django sites edx",
    "author": "edX",
    "author_email": "oscm@edx.org",
    "download_url": "https://files.pythonhosted.org/packages/56/be/f1fd2ce4bb390c0bb79a7b386cfc09848e07a0d46715b46a00ba659dfaf8/edx_django_sites_extensions-4.2.0.tar.gz",
    "platform": null,
    "description": "Part of `edX code <http://code.edx.org/>`_.\n\nedx-django-sites-extensions  |CI|_ |Codecov|_\n=================================================\n.. |CI| image:: https://github.com/openedx/edx-django-sites-extensions/workflows/Python%20CI/badge.svg?branch=master\n.. _CI: https://github.com/openedx/edx-django-sites-extensions/actions?query=workflow%3A%22Python+CI%22\n\n.. |Codecov| image:: http://codecov.io/github/edx/edx-django-sites-extensions/coverage.svg?branch=master\n.. _Codecov: http://codecov.io/github/edx/edx-django-sites-extensions?branch=master\n\n\nThis package includes extensions to the Django \"sites\" framework\nused by Open edX Django IDAs (independently deployable applications).\n\nOverview\n--------\n\nIn order to support multitenancy in an IDA, it is helpful to make use of\nthe `Django \"sites\" framework <https://docs.djangoproject.com/en/1.9/ref/contrib/sites/>`_.\n\nOne shortcoming of the Django \"sites\" framework is the fact that the CurrentSiteMiddleware\nprovided by the framework that adds the current site to incoming requests does not allow\nyou to fall back to a site that you can configure in settings in case the current site\ncannot be determined from the host of the incoming request.\n\nThe Django app provided by this package overcomes this issue by monkey patching the\ndjango.contrib.sites.models.SiteManager.get_current() function which is called by the\nCurrentSiteMiddleware to determine the current site. The patched version of this function\nwill first try to determine the current site by checking the host of the incoming request\nand attempting to match a site by domain. If a site cannot be found this way, it will fall\nback to the default site configured by setting the SITE_ID setting.\n\nAnother issue with the Django \"sites\" framework is that it uses an in-memory cache of Site\nmodels which makes it difficult to update models associated with the Site model via Django\nadmin and have those updates be reflected across all Python processes in a multi-process\napplication environment.\n\nAgain the Django app provided by this package monkey patches the private SiteManager query\nfunctions that implement the in-memory caching mechanism to add a configurable timeout to\nthe Site cache allowing model updates to be reflected across all processes after the specified\ntimeout.\n\nTo enable this functionality in your Django project:\n\nInstall this package in your python environment\n    ::\n\n    $ pip install edx-django-sites-extensions\n\nAdd :code:`django.contrib.sites.middleware.CurrentSiteMiddleware` to your :code:`MIDDLEWARE_CLASSES` list.\n\nSet the :code:`SITE_ID` setting::\n\n    SITE_ID = 1\n\nThis package also provides a mechanism for settings up URL redirects for your application.\nIt makes use of the Django redirects app and provides middleware which will check for\nRedirect models whose old_path field matches the path of the incoming request and redirects\nthose requests to the new_path of the Redirect model.\n\nTo enable this functionality in your Django project:\n\nInstall this package in your python environment\n    ::\n\n        $ pip install edx-django-sites-extensions\n\nAdd :code:`django_sites_extensions.middleware.RedirectMiddleware` to your :code:`MIDDLEWARE_CLASSES` list.\n\nYou can then use Django admin to create Redirect models.\n\nDocumentation\n-------------\n\nThe docs for edx-django-sites-extensions are on Read the Docs:  https://edx-django-sites-extensions.readthedocs.org.\n\nLicense\n-------\n\nThe code in this repository is licensed under LICENSE_TYPE unless\notherwise noted.\n\nPlease see ``LICENSE.txt`` for details.\n\nHow To Contribute\n-----------------\n\nContributions are very welcome.\n\nPlease read `How To Contribute <https://github.com/openedx/.github/blob/master/CONTRIBUTING.md>`_ for details.\n\n\nReporting Security Issues\n-------------------------\n\nPlease do not report security issues in public. Please email security@openedx.org.\n\nMailing List and IRC Channel\n----------------------------\n\nYou can discuss this code in the `edx-code Google Group <https://groups.google.com/forum/#!forum/edx-code>`_.\n",
    "bugtrack_url": null,
    "license": "AGPL",
    "summary": "Custom extensions for the Django sites framework",
    "version": "4.2.0",
    "project_urls": {
        "Homepage": "https://github.com/openedx/edx-django-sites-extensions"
    },
    "split_keywords": [
        "django",
        "sites",
        "edx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "37907ea7ca60822106bbb933a8a96c7d3e090575d2097a73278a315e17ffeacb",
                "md5": "39dacf0ad5953082f1f0f26cdf7e5c6b",
                "sha256": "791ae323e5e9cab553a02e2ac974a5d572ac458fb84829b2f2eaec5b4c5724db"
            },
            "downloads": -1,
            "filename": "edx_django_sites_extensions-4.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "39dacf0ad5953082f1f0f26cdf7e5c6b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 18886,
            "upload_time": "2024-04-18T15:26:11",
            "upload_time_iso_8601": "2024-04-18T15:26:11.412389Z",
            "url": "https://files.pythonhosted.org/packages/37/90/7ea7ca60822106bbb933a8a96c7d3e090575d2097a73278a315e17ffeacb/edx_django_sites_extensions-4.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "56bef1fd2ce4bb390c0bb79a7b386cfc09848e07a0d46715b46a00ba659dfaf8",
                "md5": "dd1dc11f0ea2ab072431f2b9e0e87ee4",
                "sha256": "1745b0e85b406a10b4f9cfcbfcf808c3f5f2865ed64400a3658a35ec0f2d9344"
            },
            "downloads": -1,
            "filename": "edx_django_sites_extensions-4.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "dd1dc11f0ea2ab072431f2b9e0e87ee4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19495,
            "upload_time": "2024-04-18T15:26:13",
            "upload_time_iso_8601": "2024-04-18T15:26:13.078831Z",
            "url": "https://files.pythonhosted.org/packages/56/be/f1fd2ce4bb390c0bb79a7b386cfc09848e07a0d46715b46a00ba659dfaf8/edx_django_sites_extensions-4.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-18 15:26:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "openedx",
    "github_project": "edx-django-sites-extensions",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "edx-django-sites-extensions"
}
        
edX
Elapsed time: 0.20709s