Acquisition

A mechanism that allows objects to obtain attributes from the containment hierarchy they're in.
Download

Acquisition Ranking & Summary

Advertisement

  • Rating:
  • License:
  • ZPL
  • Price:
  • FREE
  • Publisher Name:
  • Zope Corporation and Contributors
  • Publisher web site:
  • http://zope org

Acquisition Tags


Acquisition Description

A mechanism that allows objects to obtain attributes from the containment hierarchy they're in. Zope implements acquisition with "Extension Class" mix-in classes. To use acquisition your classes must inherit from an acquisition base class. For example:>>> import ExtensionClass, Acquisition>>> class C(ExtensionClass.Base):... color='red'>>> class A(Acquisition.Implicit):... def report(self):... print self.color...>>> a = A()>>> c = C()>>> c.a = a>>> c.a.report()red>>> d = C()>>> d.color = 'green'>>> d.a = a>>> d.a.report()green>>> a.report() # raises an attribute errorTraceback (most recent call last): ...AttributeError: colorThe class A inherits acquisition behavior from Acquisition.Implicit. The object, a, "has" the color of objects c and d when it is accessed through them, but it has no color by itself. The object a obtains attributes from its environment, where its environment is defined by the access path used to reach a. Requirements: · Python What's New in This Release: · Fix iteration proxying to pass self acquisition-wrapped into both __iter__ as well as __getitem__ · Add tests for the __getslice__ proxying, including open-ended slicing.


Acquisition Related Software