This package provides a metaclass that allows classes implemented in extension modules (typically written in C) to be subclassed in Python. It's primarily used in legacy Python applications, notably within the Zope and Plone ecosystems, to provide features like a class initializer (`__class_init__`) and the acquisition-oriented `__of__` protocol, which predates some modern Python features. The current version is 6.2 and it is actively maintained by the Zope Foundation.
pip install extensionclassVerified import paths — ran on the pinned version, not inferred.
This example demonstrates the core `ExtensionClass.Base` and its `__of__` protocol, which is central to Zope's acquisition system. When an instance of `Item` is accessed via `container.item1`, the `__of__` method on `Item` is invoked, receiving the `container` as its `parent` argument.
Evaluate if standard Python class mechanisms (e.g., properties, descriptors, `__slots__`, mixins, or standard inheritance) can achieve the desired outcome without `ExtensionClass`.
Thoroughly understand Zope's acquisition documentation if utilizing `__of__`. Be explicit about object references and their lifetimes to avoid unintended side effects from re-parenting.
Ensure `extensionclass` is updated to version 4.4 or higher to benefit from compilation fixes and improved platform compatibility.
Ensure the class intended to use `__of__` (or `ComputedAttribute`, `MethodObject` for acquisition-aware behavior) explicitly inherits from `ExtensionClass.Base`: `class MyClass(Base): ...`
Refactor the class hierarchy to ensure a single, compatible metaclass is used, or explicitly define a custom metaclass that correctly inherits from all necessary base metaclasses. In modern Python 3, directly assigning `__metaclass__` is less common than inheriting from `type` or another metaclass directly.
No dependency data recorded yet.