summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2019-10-02 10:00:43 -0500
committerGitHub <noreply@github.com>2019-10-02 10:00:43 -0500
commitbe62391821676393b7ad5ab51655892e991c2ae0 (patch)
tree0225eee416abdeecefb360bc940f39a8ab5cf910
parent00ac1f913ee7068babcf1fd482eb91dbd04d5ec2 (diff)
parent2bf1b2f11cf65ae39a1e0e8bc51937443bcaa033 (diff)
downloadpyramid-be62391821676393b7ad5ab51655892e991c2ae0.tar.gz
pyramid-be62391821676393b7ad5ab51655892e991c2ae0.tar.bz2
pyramid-be62391821676393b7ad5ab51655892e991c2ae0.zip
Merge pull request #3510 from mmerickel/scan-categories
modify the default scan categories to be limited to only 'pyramid'
-rw-r--r--CHANGES.rst6
-rw-r--r--src/pyramid/config/__init__.py23
-rw-r--r--tests/test_config/test_init.py2
3 files changed, 23 insertions, 8 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index c52da1b76..400e6d896 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -103,6 +103,12 @@ Backward Incompatibilities
by the default execution policy.
See https://github.com/Pylons/pyramid/pull/3496
+- ``pyramid.config.Configurator.scan`` will no longer, by default, execute
+ Venusian decorator callbacks registered for categories other than
+ ``'pyramid'``. To find any decorator regardless of category, specify
+ ``config.scan(..., categories=None)``.
+ See https://github.com/Pylons/pyramid/pull/3510
+
Documentation Changes
---------------------
diff --git a/src/pyramid/config/__init__.py b/src/pyramid/config/__init__.py
index cf1bfad44..4e22b946e 100644
--- a/src/pyramid/config/__init__.py
+++ b/src/pyramid/config/__init__.py
@@ -814,7 +814,12 @@ class Configurator(
# this is *not* an action method (uses caller_package)
def scan(
- self, package=None, categories=None, onerror=None, ignore=None, **kw
+ self,
+ package=None,
+ categories=('pyramid',),
+ onerror=None,
+ ignore=None,
+ **kw
):
"""Scan a Python package and any of its subpackages for objects
marked with :term:`configuration decoration` such as
@@ -829,12 +834,12 @@ class Configurator(
The ``categories`` argument, if provided, should be the
:term:`Venusian` 'scan categories' to use during scanning. Providing
this argument is not often necessary; specifying scan categories is
- an extremely advanced usage. By default, ``categories`` is ``None``
- which will execute *all* Venusian decorator callbacks including
- :app:`Pyramid`-related decorators such as
- :class:`pyramid.view.view_config`. See the :term:`Venusian`
- documentation for more information about limiting a scan by using an
- explicit set of categories.
+ an extremely advanced usage. By default, ``categories`` is
+ ``['pyramid']`` which will execute only :app:`Pyramid`-related Venusian
+ decorator callbacks such as from :class:`pyramid.view.view_config`.
+ See the :term:`Venusian` documentation for more information about
+ limiting a scan by using an explicit set of categories. Pass ``None``
+ to pick up *all* Venusian decorators.
The ``onerror`` argument, if provided, should be a Venusian
``onerror`` callback function. The onerror function is passed to
@@ -872,6 +877,10 @@ class Configurator(
.. versionadded:: 1.3
The ``ignore`` argument.
+ .. versionchanged:: 2.0
+ The ``categories`` argument now defaults to ``['pyramid']`` instead
+ of ``None`` to control which decorator callbacks are executed.
+
"""
package = self.maybe_dotted(package)
if package is None: # pragma: no cover
diff --git a/tests/test_config/test_init.py b/tests/test_config/test_init.py
index 661654ef0..5ca33178a 100644
--- a/tests/test_config/test_init.py
+++ b/tests/test_config/test_init.py
@@ -1113,7 +1113,7 @@ test_config.dummy_include2"""
def test_scan_integration_with_extra_kw(self):
config = self._makeOne(autocommit=True)
- config.scan('tests.test_config.pkgs.scanextrakw', a=1)
+ config.scan('tests.test_config.pkgs.scanextrakw', a=1, categories=None)
self.assertEqual(config.a, 1)
def test_scan_integration_with_onerror(self):