summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/adapter.rst27
-rw-r--r--docs/conf.py4
2 files changed, 28 insertions, 3 deletions
diff --git a/docs/adapter.rst b/docs/adapter.rst
index 6a728a3..50fcf8c 100644
--- a/docs/adapter.rst
+++ b/docs/adapter.rst
@@ -202,11 +202,11 @@ factories:
... pass
>>> @zope.interface.implementer(IR)
- ... class X:
+ ... class X(object):
... pass
>>> @zope.interface.implementer(IProvide1)
- ... class Y:
+ ... class Y(object):
... def __init__(self, context):
... self.context = context
@@ -238,6 +238,29 @@ We can register and lookup by name too:
>>> y.context is x
True
+Passing ``super`` objects works as expected to find less specific adapters:
+
+.. doctest::
+
+ >>> class IDerived(IR):
+ ... pass
+ >>> @zope.interface.implementer(IDerived)
+ ... class Derived(X):
+ ... pass
+ >>> class DerivedAdapter(Y):
+ ... def query_next(self):
+ ... return registry.queryAdapter(
+ ... super(type(self.context), self.context),
+ ... IProvide1)
+ >>> registry.register([IDerived], IProvide1, '', DerivedAdapter)
+ >>> derived = Derived()
+ >>> adapter = registry.queryAdapter(derived, IProvide1)
+ >>> adapter.__class__.__name__
+ 'DerivedAdapter'
+ >>> adapter = adapter.query_next()
+ >>> adapter.__class__.__name__
+ 'Y'
+
When the adapter factory produces ``None``, then this is treated as if no
adapter has been found. This allows us to prevent adaptation (when desired)
and let the adapter factory determine whether adaptation is possible based on
diff --git a/docs/conf.py b/docs/conf.py
index 8a0f86a..464f652 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -17,7 +17,9 @@ import os
import pkg_resources
sys.path.append(os.path.abspath('../src'))
rqmt = pkg_resources.require('zope.interface')[0]
-
+# Import and document the pure-python versions of things; they tend to have better
+# docstrings and signatures.
+os.environ['PURE_PYTHON'] = '1'
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.