Module shadow

[Contents] [Prev] [Next]
Table of Contents


The shadow module provides objects that act as intermediaries for other objects, exposing selected attributes of the original object and masking the rest. Like the Python Bastion module, shadow provides a controlled interface between trusted and untrusted code.

A close cousin of bastions, shadow objects offer a different form of access to the object being reflected:


This module defines the following class:

shadow (original, defers)
Construct a shadow object for original, coupling access to attributes listed in the defers sequence so that get and set operations of those attributes in the shadow are mapped to the original object.

Getting values in the shadow for attributes listed in defers gets the values from the original, and changing values for those attributes in the shadow applies the changes to the attributes of original. Getting the value of an attribute listed in defers which does not exist on the original object causes an AttributeError exception. Setting an attribute listed in defers that does not already exist in the original causes it to be created in the original.

Conversely, getting and setting attribute values for attributes not on the defers list applies, in the normal ways, only to the shadow object, not to the original.

No special methods are provided, but many disciplines for attribute management are implemented to provide the required functionality.


This module defines the following function:

Simple test of the shadow class.

See Also

Chapter on restricted execution in the Python Library Reference.

Table of Contents

[Contents] [Prev] [Next]
Copyright © 1998 by the Corporation for National Research Initiatives.