Skip to content

Commit

Permalink
Improve interface documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
d-maurer committed Dec 2, 2021
1 parent 5d95834 commit d848dac
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
4.10 (unreleased)
-----------------

- Nothing changed yet.
- Improve interface documentation


4.9 (2021-08-19)
Expand Down
63 changes: 62 additions & 1 deletion src/Acquisition/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"""Acquisition z3 interfaces.
$Id$
For details, see
`README.rst <https://github.com/zopefoundation/Acquisition#readme>`_
"""

from zope.interface import Attribute
Expand All @@ -32,11 +35,69 @@ def __of__(context):
class IAcquisitionWrapper(Interface):

"""Wrapper object for acquisition.
A wrapper encapsulates an object, ``aq_self``, and a parent ``aq_parent``.
Both of them can in turn be wrappers.
Informally, the wrapper indicates that the object has been
accessed via the parent.
The wrapper essentially behaves like the object but may (in
some cases) also show behavior of the parent.
A wrapper is called an "inner wrapper" if its object is not
itself a wrapper. In this case, the parent is called the object's
container.
There are 2 kinds of wrappers - implicit and explicit wrappers:
Implicit wrappers search attributes in the parent by default
in contrast to explicit wrappers.
"""

def aq_acquire(name, filter=None, extra=None, explicit=True, default=0,
containment=0):
containment=False):
"""Get an attribute, acquiring it if necessary.
The search first searches in the object and if this search
is unsuccessful, it may continue the search in the parent.
When the attribute is found and *filter* is not None,
*filter* is called with the parameters:
self
the object ``aq_acquire`` was called on
container
the container the attribute was found in
*name*
``aq_acquire`` parameter
value
the attribute value
*extra*
``aq_acquire`` parameter
If the call returns true, *value* is returned,
otherwise the search continues.
*explicit* controls whether the attribute is also searched
in the parent. This is always the case for implicit
wrappers. For explicit wrappers, the parent
is only searched if *explicit* is true.
*default* controls what happens when the attribute was not found.
In this case, *default* is returned when it was passed;
otherwise, ``AttributeError`` is raised.
(Note: in contradiction to the signature above, *default* has
actually a "not given" marker as default, not ``0``).
*containment* controls whether the search is restricted
to the "containment hierarchy". In the corresponding search,
the parent of a wrapper *w* is only searched if *w* is an inner
wrapper, i.e. if the object of *w* is not a wrapper and the parent
is the object's container.
"""

def aq_inContextOf(obj, inner=1):
Expand Down

0 comments on commit d848dac

Please sign in to comment.