Skip to content
Myr

Merge pull request #1071 from bblackifyme/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Clarify documentation for complex.rst - Ensuring Object Creation

authored by Jay Crotts · committed by GitHub · parents 6e7d6d6, 1cf051a · Browse files · 1 file+3 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−2 removed

  • other:+3 added−2 removed

1 file+3 added−2 removed

modified:docs/complex.rst+3 added-2 removed
185 unmodified lines
186The above example only works if there was an outer command that created a187``Repo`` object and stored it in the context. For some more advanced use188cases, this might become a problem. The default behavior of189:func:`make_pass_decorator` is to call :meth:`Context.find_object`190which will find the object. If it can't find the object, it will raise an191error. The alternative behavior is to use :meth:`Context.ensure_object`190which will find the object. If it can't find the object,191:meth:`make_pass_decorator` will raise an error.192The alternative behavior is to use :meth:`Context.ensure_object`193which will find the object, and if it cannot find it, will create one and194store it in the innermost context. This behavior can also be enabled for195:func:`make_pass_decorator` by passing ``ensure=True``:196
24 unmodified lines