diff --git a/README.md b/README.md index 94f9d2915aa8dd4c5db91405fd858693c4f977ac..3fe81ecc4a31199abfe5e80893f6d8202b103318 100644 --- a/README.md +++ b/README.md @@ -126,12 +126,14 @@ LDP_RDF_CONTEXT = 'https://cdn.happy-dev.fr/owl/hdcontext.jsonld' DJANGOLDP_PACKAGES = [] SITE_URL = 'http://localhost:8000' BASE_URL = SITE_URL +PERMISSIONS_CACHE = True ``` * `LDP_RDF_CONTEXT` tells DjangoLDP where our RDF [ontology](https://www.w3.org/standards/semanticweb/ontology) is defined, which will be returned as part of our views in the 'context' field. This is a web URL and you can visit the value to view the full ontology online. The ontology can be a string, as in the example, but it can also be a dictionary, or a list of ontologies (see the [JSON-LD spec](https://json-ld.org) for examples) * `DJANGOLDP_PACKAGES` defines which other [DjangoLDP packages](https://git.happy-dev.fr/startinblox/djangoldp-packages) we're using in this installation * `SITE_URL` is the URL serving the site, e.g. `https://example.com/`. Note that if you include the DjangoLDP urls in a nested path (e.g. `https://example.com/api/`), then `SITE_URL` will need to be set to this value * `BASE_URL` may be different from SITE_URL, e.g. `https://example.com/app/` +* `PERMISSIONS_CACHE` Activate cache on Permissions (Set to True Recommended) 4. You can also register your model for the django administration site diff --git a/djangoldp/permissions.py b/djangoldp/permissions.py index 55598b66a69a0883ea8431b97562e14ce1cbeb37..706d0df7d301f04d0d52cb431bdee7a5cc7ad5e7 100644 --- a/djangoldp/permissions.py +++ b/djangoldp/permissions.py @@ -1,4 +1,5 @@ import time +from django.conf import settings from django.contrib.auth.models import _user_get_all_permissions from django.core.exceptions import PermissionDenied from django.db.models.base import ModelBase @@ -19,7 +20,7 @@ class LDPPermissions(DjangoObjectPermissions): perms_cache = { 'time': time.time() } - with_cache = True + with_cache = settings.PERMISSIONS_CACHE @classmethod def invalidate_cache(cls): diff --git a/djangoldp/tests/settings_default.py b/djangoldp/tests/settings_default.py index 3686e77775e31fcf1c30567e72db2896ae95c187..7c7cb1b2b2c41f3eb2f1619ca4f4e6bace9f026b 100644 --- a/djangoldp/tests/settings_default.py +++ b/djangoldp/tests/settings_default.py @@ -93,3 +93,4 @@ LDP_RDF_CONTEXT={ } SEND_BACKLINKS=False GUARDIAN_AUTO_PREFETCH = True +PERMISSIONS_CACHE = True