Proxy API Documentation

class Subject[source]

Bases: ABC

Defines the common interface for the RealSubject and Proxy.

abstractmethod request(resource)[source]

Handle the client’s request.

Parameters:

resource (str) – The resource being requested.

Return type:

None

class RealSubject[source]

Bases: Subject

Performs the actual work of handling requests.

request(resource)[source]

Handles the request and simulates actual processing.

Parameters:

resource (str) – The resource being accessed.

Return type:

None

class Proxy(is_authenticated)[source]

Bases: Subject

Controls access to the RealSubject and adds additional functionality like authentication.

Parameters:

is_authenticated (bool)

__init__(is_authenticated)[source]

Initialize the Proxy with authentication status.

Parameters:

is_authenticated (bool) – Whether the client is authenticated.

request(resource)[source]

Handle the request by checking authentication and delegating to RealSubject.

Parameters:

resource (str) – The resource being requested.

Return type:

None