Acquisition

6.2 · active · verified Thu Apr 16

Acquisition is a mechanism that allows objects to obtain attributes from the containment hierarchy they're in. This foundational Zope library, currently at version 6.2, facilitates dynamic attribute lookup based on an object's position within a hierarchy or explicitly set context. While it does not have a fixed release cadence, it is actively maintained by the Zope Foundation.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates basic implicit acquisition. An object `b` acquires attributes from `a` when `a` is set as its context using `__of__`. Subsequent objects in the context chain can also acquire attributes from higher up the hierarchy.

from Acquisition import Implicit

class C(Implicit):
    pass

a = C()
b = C()

a.color = "red"

# 'b' acquires 'color' from 'a' because 'a' is put into b's context
print(b.__of__(a).color)

class X(Implicit):
    pass

x = X().__of__(b.__of__(a))

# 'x' acquires 'color' from 'a' through 'b'
print(x.color)

view raw JSON →