Skip to content

Commit 34c2a80

Browse files
authored
Merge pull request pypa#676 from maggyero/patch-1
Update creating-and-discovering-plugins.rst
2 parents ec33c54 + 9f747bb commit 34c2a80

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

source/guides/creating-and-discovering-plugins.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ discover all of the Flask plugins installed:
2828
import importlib
2929
import pkgutil
3030
31-
flask_plugins = {
31+
discovered_plugins = {
3232
name: importlib.import_module(name)
3333
for finder, name, ispkg
3434
in pkgutil.iter_modules()
3535
if name.startswith('flask_')
3636
}
3737
3838
If you had both the `Flask-SQLAlchemy`_ and `Flask-Talisman`_ plugins installed
39-
then ``flask_plugins`` would be:
39+
then ``discovered_plugins`` would be:
4040

4141
.. code-block:: python
4242
@@ -80,16 +80,16 @@ under that namespace:
8080
# the name.
8181
return pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + ".")
8282
83-
myapp_plugins = {
83+
discovered_plugins = {
8484
name: importlib.import_module(name)
8585
for finder, name, ispkg
8686
in iter_namespace(myapp.plugins)
8787
}
8888
8989
Specifying ``myapp.plugins.__path__`` to :func:`~pkgutil.iter_modules` causes
9090
it to only look for the modules directly under that namespace. For example,
91-
if you have installed distributions that provide the modules ``myapp.plugin.a``
92-
and ``myapp.plugin.b`` then ``myapp_plugins`` in this case would be:
91+
if you have installed distributions that provide the modules ``myapp.plugins.a``
92+
and ``myapp.plugins.b`` then ``discovered_plugins`` in this case would be:
9393

9494
.. code-block:: python
9595
@@ -98,11 +98,11 @@ and ``myapp.plugin.b`` then ``myapp_plugins`` in this case would be:
9898
'b': <module: 'myapp.plugins.b'>,
9999
}
100100
101-
This sample uses a sub-package as the namespace package (``myapp.plugin``), but
101+
This sample uses a sub-package as the namespace package (``myapp.plugins``), but
102102
it's also possible to use a top-level package for this purpose (such as
103103
``myapp_plugins``). How to pick the namespace to use is a matter of preference,
104-
but it's not recommended to make your project's main top-level package (
105-
``myapp`` in this case) a namespace package for the purpose of plugins, as one
104+
but it's not recommended to make your project's main top-level package
105+
(``myapp`` in this case) a namespace package for the purpose of plugins, as one
106106
bad plugin could cause the entire namespace to break which would in turn make
107107
your project unimportable. For the "namespace sub-package" approach to work,
108108
the plugin packages must omit the :file:`__init__.py` for your top-level
@@ -142,13 +142,13 @@ Then you can discover and load all of the registered entry points by using
142142
143143
import pkg_resources
144144
145-
plugins = {
145+
discovered_plugins = {
146146
entry_point.name: entry_point.load()
147147
for entry_point
148148
in pkg_resources.iter_entry_points('myapp.plugins')
149149
}
150150
151-
In this example, ``plugins`` would be :
151+
In this example, ``discovered_plugins`` would be:
152152

153153
.. code-block:: python
154154

0 commit comments

Comments
 (0)