summaryrefslogtreecommitdiff
path: root/docs/api
diff options
context:
space:
mode:
Diffstat (limited to 'docs/api')
-rw-r--r--docs/api/adapter.rst17
-rw-r--r--docs/api/interface.rst6
-rw-r--r--docs/api/persistent.rst6
3 files changed, 17 insertions, 12 deletions
diff --git a/docs/api/adapter.rst b/docs/api/adapter.rst
index 992d9e5..1cfeb8f 100644
--- a/docs/api/adapter.rst
+++ b/docs/api/adapter.rst
@@ -358,14 +358,20 @@ Let's register some adapters first:
>>> gsm.registerAdapter(Comp, [None], I5, 'foo')
Now we get all the adapters that are registered for ``ob`` that provide
-``I5``:
+``I5`` (note that on Python 2 the names will be ``unicode``):
.. doctest::
>>> from zope.component import getAdapters
>>> adapters = sorted(getAdapters((ob,), I5))
- >>> [(name, adapter.__class__.__name__) for name, adapter in adapters]
- [(u'', 'Comp'), (u'foo', 'Comp')]
+ >>> [(str(name), adapter.__class__.__name__) for name, adapter in adapters]
+ [('', 'Comp'), ('foo', 'Comp')]
+ >>> try:
+ ... unicode = unicode
+ ... except NameError:
+ ... unicode = str # Python 3
+ >>> [isinstance(name, unicode) for name, _ in adapters]
+ [True, True]
Note that the output doesn't include None values. If an adapter
factory returns None, it is as if it wasn't present.
@@ -374,8 +380,8 @@ factory returns None, it is as if it wasn't present.
>>> gsm.registerAdapter(lambda context: None, [I1], I5, 'nah')
>>> adapters = sorted(getAdapters((ob,), I5))
- >>> [(name, adapter.__class__.__name__) for name, adapter in adapters]
- [(u'', 'Comp'), (u'foo', 'Comp')]
+ >>> [(str(name), adapter.__class__.__name__) for name, adapter in adapters]
+ [('', 'Comp'), ('foo', 'Comp')]
Subscription Adapters
@@ -402,4 +408,3 @@ Helpers for Declaring / Testing Adapters
from zope.component.testing import tearDown
tearDown()
-
diff --git a/docs/api/interface.rst b/docs/api/interface.rst
index fbaf57f..ff456f7 100644
--- a/docs/api/interface.rst
+++ b/docs/api/interface.rst
@@ -115,7 +115,7 @@ We can register ``IDemo`` as providing more than one interface:
False
>>> queryInterface('zope.component.tests.examples.IQI') is None
True
-
+
>>> provideInterface('', IQI, ITestType)
>>> ITestType.providedBy(IQI)
True
@@ -175,8 +175,8 @@ We can register ``IDemo`` as providing more than one interface:
>>> provideInterface('', ISII, ITestType)
>>> ITestType.providedBy(ISII)
True
- >>> searchInterfaceIds(None, 'zope.component.tests.examples.ISII')
- [u'zope.component.tests.examples.ISII']
+ >>> [str(x) for x in searchInterfaceIds(None, 'zope.component.tests.examples.ISII')]
+ ['zope.component.tests.examples.ISII']
.. testcleanup::
diff --git a/docs/api/persistent.rst b/docs/api/persistent.rst
index 69c9e4b..eaad08f 100644
--- a/docs/api/persistent.rst
+++ b/docs/api/persistent.rst
@@ -167,11 +167,11 @@ We want to make sure that we see updates corrextly.
>>> import persistent
>>> import transaction
>>> from zope.interface import Interface
- >>> from zope.interface import implements
+ >>> from zope.interface import implementer
>>> class IFoo(Interface):
... pass
- >>> class Foo(persistent.Persistent):
- ... implements(IFoo)
+ >>> @implementer(IFoo)
+ ... class Foo(persistent.Persistent):
... name = ''
... def __init__(self, name=''):
... self.name = name