Chapter 9. The Proxy Pattern

In some applications, we want to execute one or more important action before accessing an object. An example is accessing sensitive information. Before allowing any user to access sensitive information, we want to make sure that the user has sufficient privileges. A similar situation exists in operating systems. A user is required to have administrative privileges to install new programs system-wide.

The important action is not necessarily related to security issues. Lazy initialization [j.mp/wikilazy] is another case; we want to delay the creation of a computationally expensive object until the first time the user actually needs to use it.

Such actions are typically performed using the Proxy design pattern. The pattern ...

Get Mastering Python Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.