Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #229: Document constant NONE vs Python's None #255

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

robhudson
Copy link
Member

No description provided.

@robhudson
Copy link
Member Author

/cc @janbrasna

@janbrasna
Copy link
Contributor

Lovely. I actually after several attempts to improve the docs realized that the info was there all the time, just in a different place:

In the above example, the constant ``NONE`` is converted to the CSP keyword ``"'none'"`` and
is distinct from Python's ``None`` value. The CSP keyword ``'none'`` is a special value that
signifies that you do not want any sources for this directive. The ``None`` value is a
Python keyword that represents the absence of a value and when used as the value of a directive,
it will remove the directive from the policy.
This is useful when using the ``@csp_replace`` decorator to effectively clear a directive from
the base configuration as defined in the settings. For example, if the Django settings the
``frame-ancestors`` directive is set to a list of sources and you want to remove the
``frame-ancestors`` directive from the policy for this view:

But this addition is a great improvement nonetheless, for those not reading the doc linearly and just skimming through the examples/defaults etc., to help avoiding this quite an unfortunate confusion;)

Copy link
Contributor

@janbrasna janbrasna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(only adding a few naïve questions out of ignorance…)

docs/configuration.rst Outdated Show resolved Hide resolved
docs/configuration.rst Outdated Show resolved Hide resolved
@robhudson robhudson force-pushed the 229-doc-NONE-vs-None branch 2 times, most recently from 766894f to 806e07c Compare January 20, 2025 16:20
@robhudson robhudson force-pushed the 229-doc-NONE-vs-None branch from 806e07c to fb5f80a Compare January 20, 2025 17:20
@robhudson robhudson merged commit e6ae74e into main Jan 20, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants