@@ -14,7 +14,7 @@ changing or extending the behavior of commands. :class:`~django_typer.TyperComma
14
14
or add additional commands to a command implemented elsewhere. You can then use Django's built in
15
15
command override precedence (INSTALLED_APPS) to ensure your command is used instead of the upstream
16
16
command or give it a different name if you would like the upstream command to still be available.
17
- The :ref: `composition pattern <composition >` allows commands and groups to be added or overridden
17
+ The :ref: `plugin pattern <plugin >` allows commands and groups to be added or overridden
18
18
directly on upstream commands without inheritance. This mechanism is useful when you might expect
19
19
other apps to also modify the original command. Conflicts are resolved in INSTALLED_APPS order.
20
20
@@ -139,15 +139,15 @@ expect other apps to also modify the same command. It's also a good choice when
139
139
a different flavor of a command under a different name.
140
140
141
141
What if other apps want to alter the same command and we don't know about them, but they may end up
142
- installed along with our app? This is where the composition pattern will serve us better.
142
+ installed along with our app? This is where the plugin pattern will serve us better.
143
143
144
144
145
- .. _ composition :
145
+ .. _ plugin :
146
146
147
- Composition
147
+ Plugins
148
148
-----------
149
149
150
- **The composition pattern allows us to add or override commands and groups on an upstream command
150
+ **The plugin pattern allows us to add or override commands and groups on an upstream command
151
151
directly without overriding it or changing its name. This allows downstream apps that know
152
152
nothing about each other to add their own behavior to the same command. If there are conflicts
153
153
they are resolved in INSTALLED_APPS order. **
@@ -159,7 +159,7 @@ Because we're now mostly working at the level of our particular site we may want
159
159
backup logic. For instance, lets say we know our site will always run on sqlite and we prefer
160
160
to just copy the file to backup our database. Lets also pretend that it is useful for us to backup
161
161
the python stack (e.g. requirements.txt) running on our server. To do that we can use the
162
- composition pattern to add our environment backup routine and override the database routine from
162
+ plugin pattern to add our environment backup routine and override the database routine from
163
163
the upstream backup app. Our app tree now might look like this:
164
164
165
165
.. code-block :: text
@@ -218,7 +218,7 @@ this:
218
218
do this inside ready() because conflicts are resolved in the order in which the extension
219
219
modules are registered and ready() methods are called in INSTALLED_APPS order.
220
220
221
- For composition to work, we'll need to re-mplement media from above as a composed extension
221
+ For plugins to work, we'll need to re-mplement media from above as a composed extension
222
222
and that would look like this:
223
223
224
224
.. literalinclude :: ../../django_typer/tests/apps/examples/extensions/media2/management/extensions/backup.py
@@ -310,18 +310,18 @@ You may even override the initializer of a predefined group:
310
310
and groups.
311
311
"""
312
312
313
- When Does Composition Make Sense?
313
+ When Do Plugins Make Sense?
314
314
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315
315
316
- Composition can be used to group like behavior together under a common root command. This can be
316
+ Plugins can be used to group like behavior together under a common root command. This can be
317
317
thought of as a way to namespace CLI tools or easily share significant code between tools that have
318
318
common initialization logic. Moreover it allows you to do this safely and in a way that can be
319
319
deterministically controlled in settings. Most use cases are not this complex and even our backup
320
320
example could probably better be implemented as a batch of commands.
321
321
322
322
Django apps are great for forcing separation of concerns on your code base. In large self contained
323
323
projects its often a good idea to break your code into apps that are as self contained as possible.
324
- Composition can be a good way to organize commands in a code base that follows this pattern. It
324
+ Plugins can be a good way to organize commands in a code base that follows this pattern. It
325
325
also allows for deployments that install a subset of those apps and is therefore a good way to
326
326
organize commands in code bases that serve as a framework for a particular kind of site or that
327
327
support selecting the features to install.
0 commit comments