[Checkins] SVN: Acquisition/trunk/src/Acquisition/tests.py Whitespace
Hanno Schlichting
hannosch at hannosch.eu
Sat Apr 3 18:13:43 EDT 2010
Log message for revision 110472:
Whitespace
Changed:
U Acquisition/trunk/src/Acquisition/tests.py
-=-
Modified: Acquisition/trunk/src/Acquisition/tests.py
===================================================================
--- Acquisition/trunk/src/Acquisition/tests.py 2010-04-03 22:13:19 UTC (rev 110471)
+++ Acquisition/trunk/src/Acquisition/tests.py 2010-04-03 22:13:43 UTC (rev 110472)
@@ -70,9 +70,9 @@
cannot be found in 'a'.
Aquisition wrappers provide access to the wrapped objects
- through the attributes 'aq_parent', 'aq_self', 'aq_base'.
+ through the attributes 'aq_parent', 'aq_self', 'aq_base'.
In the example above, the expressions::
-
+
>>> c.a.aq_parent is c
1
@@ -97,28 +97,28 @@
Two styles of acquisition are supported in the current
ExtensionClass release, implicit and explicit aquisition.
-
+
Implicit acquisition
-
+
Implicit acquisition is so named because it searches for
attributes from the environment automatically whenever an
attribute cannot be obtained directly from an object or
through inheritence.
-
+
An attribute may be implicitly acquired if it's name does
not begin with an underscore, '_'.
-
+
To support implicit acquisition, an object should inherit
from the mix-in class 'Acquisition.Implicit'.
-
+
Explicit Acquisition
-
+
When explicit acquisition is used, attributes are not
automatically obtained from the environment. Instead, the
method 'aq_aquire' must be used, as in::
-
+
print c.a.aq_acquire('color')
-
+
To support explicit acquisition, an object should inherit
from the mix-in class 'Acquisition.Explicit'.
@@ -206,31 +206,31 @@
For example, in::
>>> from Acquisition import Explicit
-
+
>>> class HandyForTesting:
... def __init__(self, name): self.name=name
... def __str__(self):
... return "%s(%s)" % (self.name, self.__class__.__name__)
... __repr__=__str__
-
+
>>> class E(Explicit, HandyForTesting):
... pass
-
+
>>> class Nice(HandyForTesting):
... isNice=1
... def __str__(self):
... return HandyForTesting.__str__(self)+' and I am nice!'
... __repr__=__str__
-
+
>>> a = E('a')
>>> a.b = E('b')
>>> a.b.c = E('c')
>>> a.p = Nice('spam')
>>> a.b.p = E('p')
-
+
>>> def find_nice(self, ancestor, name, object, extra):
... return hasattr(object,'isNice') and object.isNice
-
+
>>> print a.b.c.aq_acquire('p', find_nice)
spam(Nice) and I am nice!
@@ -258,13 +258,13 @@
Consider the following example::
>>> from Acquisition import Implicit
-
+
>>> class C(Implicit):
... def __init__(self, name): self.name=name
... def __str__(self):
... return "%s(%s)" % (self.name, self.__class__.__name__)
... __repr__=__str__
-
+
>>> a = C("a")
>>> a.b = C("b")
>>> a.b.pref = "spam"
@@ -323,9 +323,9 @@
'a' is searched no more than once, even though it is wrapped three
times.
-.. [1] Gil, J., Lorenz, D.,
+.. [1] Gil, J., Lorenz, D.,
"Environmental Acquisition--A New Inheritance-Like Abstraction Mechanism",
- http://www.bell-labs.com/people/cope/oopsla/Oopsla96TechnicalProgramAbstracts.html#GilLorenz,
+ http://www.bell-labs.com/people/cope/oopsla/Oopsla96TechnicalProgramAbstracts.html#GilLorenz,
OOPSLA '96 Proceedings, ACM SIG-PLAN, October, 1996
$Id$
@@ -368,7 +368,7 @@
Traceback (most recent call last):
...
AttributeError: x
-
+
>>> Acquisition.aq_acquire(c, 'id',
... lambda searched, parent, name, ob, extra: extra)
Traceback (most recent call last):
@@ -409,8 +409,8 @@
>>> Acquisition.aq_self(c) is c
1
-
-
+
+
"""
def test_simple():
@@ -475,7 +475,7 @@
Traceback (most recent call last):
...
AttributeError: x
-
+
>>> a.b.c.aq_acquire('id',
... lambda searched, parent, name, ob, extra: extra)
Traceback (most recent call last):
@@ -497,7 +497,7 @@
>>> Acquisition.aq_acquire(a.b.c, 'y')
42
-
+
>>> Acquisition.aq_acquire(a.b.c, 'id',
... lambda searched, parent, name, ob, extra: extra)
Traceback (most recent call last):
@@ -685,19 +685,19 @@
>>> show(a.a1.a11.a2.a21.aq_inner.aq_parent.aq_inner.aq_parent)
a
-
+
>>> a.a1.a11.a2.a21.aq_chain
[a21, a2, a11, a1, a]
-
+
>>> a.a1.a11.a2.a21.aq_inContextOf(a)
1
-
+
>>> a.a1.a11.a2.a21.aq_inContextOf(a.a2)
1
>>> a.a1.a11.a2.a21.aq_inContextOf(a.a1)
0
-
+
>>> a.a1.a11.a2.a21.aq_acquire('color')
'red'
>>> a.a1.a11.a2.a21.aq_acquire('id')
@@ -712,7 +712,7 @@
>>> a.a1.a11.a2.a21.aq_acquire('color',
... lambda ob, parent, name, v, extra: extra, 1)
'red'
-
+
>>> a.a1.y = 42
>>> a.a1.a11.a2.a21.aq_acquire('y')
42
@@ -796,13 +796,13 @@
>>> show(Acquisition.aq_parent(
... a.a1.a11.a2.a21.aq_inner.aq_parent.aq_inner))
a
-
+
>>> Acquisition.aq_chain(a.a1.a11.a2.a21)
[a21, a2, a11, a1, a]
-
+
>>> Acquisition.aq_chain(a.a1.a11.a2.a21, 1)
[a21, a2, a]
-
+
>>> Acquisition.aq_acquire(a.a1.a11.a2.a21, 'color')
'red'
>>> Acquisition.aq_acquire(a.a1.a11.a2.a21, 'id')
@@ -817,7 +817,7 @@
>>> Acquisition.aq_acquire(a.a1.a11.a2.a21, 'color',
... lambda ob, parent, name, v, extra: extra, 1)
'red'
-
+
>>> a.a1.y = 42
>>> Acquisition.aq_acquire(a.a1.a11.a2.a21, 'y')
42
@@ -829,7 +829,7 @@
"""
-
+
def test_pinball():
r"""
>>> a = I('a')
@@ -943,7 +943,7 @@
a1
|
a
-
+
"""
def test_explicit():
@@ -1003,7 +1003,7 @@
Traceback (most recent call last):
...
AttributeError: x
-
+
>>> a.b.c.aq_acquire('id',
... lambda searched, parent, name, ob, extra: extra)
Traceback (most recent call last):
@@ -1025,7 +1025,7 @@
>>> Acquisition.aq_acquire(a.b.c, 'y')
42
-
+
>>> Acquisition.aq_acquire(a.b.c, 'id',
... lambda searched, parent, name, ob, extra: extra)
Traceback (most recent call last):
@@ -1143,7 +1143,7 @@
Traceback (most recent call last):
...
AttributeError: x
-
+
>>> a.b.c.aq_acquire('id',
... lambda searched, parent, name, ob, extra: extra)
Traceback (most recent call last):
@@ -1165,7 +1165,7 @@
>>> Acquisition.aq_acquire(a.b.c, 'y')
42
-
+
>>> Acquisition.aq_acquire(a.b.c, 'id',
... lambda searched, parent, name, ob, extra: extra)
Traceback (most recent call last):
@@ -1221,7 +1221,7 @@
def test_aq_inContextOf():
- """
+ """
>>> from ExtensionClass import Base
>>> import Acquisition
@@ -1247,9 +1247,9 @@
... raise 'Program error', 'spam'
... except AttributeError: pass
A()
-
+
New test for wrapper comparisons.
-
+
>>> foo = b.a
>>> bar = b.a
>>> foo == bar
@@ -1379,14 +1379,14 @@
[D, C, A]
>>> map(Acquisition.aq_base, Acquisition.aq_chain(A.B.C.D, 1))
[D, C, A]
-
+
>>> A.B.C.D.color
'red'
>>> Acquisition.aq_get(A.B.C.D, "color", None)
'red'
>>> Acquisition.aq_get(A.B.C.D, "color", None, 1)
-
+
"""
def test_explicit_acquisition():
@@ -1414,7 +1414,7 @@
... raise 'Program error', 'spam'
... except AttributeError: pass
A
-
+
"""
def test_creating_wrappers_directly():
@@ -1593,7 +1593,7 @@
def show(x):
print showaq(x).strip()
-
+
def showaq(m_self, indent=''):
rval = ''
obj = m_self
@@ -1631,11 +1631,11 @@
>>> for B in I, E:
... class C1(B):
... pass
- ...
+ ...
... class C2(Base):
... def __del__(self):
... print 'removed'
- ...
+ ...
... a=C1('a')
... a.b = C1('a.b')
... a.b.a = a
@@ -1664,7 +1664,7 @@
... class C:
... def __del__(self):
... print 'removed'
- ...
+ ...
... a=B('a')
... a.b = B('b')
... a.a_b = a.b # circ ref through wrapper
@@ -1891,7 +1891,7 @@
class Location(object):
__parent__ = None
-
+
class ECLocation(ExtensionClass.Base):
__parent__ = None
More information about the checkins
mailing list