lib.settings¶
Settings objects and type-mapping for Django Docutils library package.
-
Docutils defaults used for web-facing django-docutils rendering.
-
Settings that require explicit unsafe opt-in before applications may override.
-
URI schemes emitted by django-docutils HTML rendering by default.
-
URI schemes that require explicit unsafe opt-in when configured.
-
django_docutils.lib.settings.DJANGO_DOCUTILS_LIB_RST = {}¶django_docutils.lib.settings.DJANGO_DOCUTILS_LIB_RST = {}¶
Settings for reStructuredText
-
django_docutils.lib.settings.unsafe_docutils_settings_allowed()¶django_docutils.lib.settings.unsafe_docutils_settings_allowed()¶
Return whether project settings may re-enable unsafe Docutils features.
- Returns:
TruewhenDJANGO_DOCUTILS_LIB_RSTsetsallow_unsafe_docutils_settings.- Return type:
Examples
>>> isinstance(unsafe_docutils_settings_allowed(), bool) True
-
django_docutils.lib.settings.get_docutils_settings(settings_overrides=None)¶django_docutils.lib.settings.get_docutils_settings(settings_overrides=None)¶
Return Docutils settings with django-docutils security defaults applied.
- Parameters:
settings_overrides (
mapping,optional) – Per-call Docutils settings layered over project configuration. Protected settings still win unless the project setsallow_unsafe_docutils_settings.- Returns:
Resolved Docutils settings safe to hand to the publisher.
- Return type:
Examples
>>> settings = get_docutils_settings() >>> settings["file_insertion_enabled"] False >>> settings["raw_enabled"] False >>> settings["_disable_config"] True
-
django_docutils.lib.settings.get_allowed_uri_schemes()¶django_docutils.lib.settings.get_allowed_uri_schemes()¶
Return normalized URI schemes allowed in rendered HTML attributes.
- Returns:
Lowercased scheme names; unsafe schemes are excluded unless the project sets
allow_unsafe_docutils_settings.- Return type:
frozenset of str
Examples
>>> "https" in get_allowed_uri_schemes() True >>> "javascript" in get_allowed_uri_schemes() False
-
django_docutils.lib.settings.reload_settings(signal, sender, setting, value, enter, **kwargs)¶django_docutils.lib.settings.reload_settings(signal, sender, setting, value, enter, **kwargs)¶
Ran when settings updated.
Examples
>>> before = dict(DJANGO_DOCUTILS_LIB_RST) >>> reload_settings(None, None, "DJANGO_DOCUTILS_LIB_RST", {"transforms": []}, True) >>> DJANGO_DOCUTILS_LIB_RST["transforms"] [] >>> reload_settings(None, None, "DJANGO_DOCUTILS_LIB_RST", dict(before), False) >>> dict(DJANGO_DOCUTILS_LIB_RST) == before True