EN: The most common applications of the Proxy pattern are lazy loading, caching, controlling the access, logging, etc. A Proxy can perform one of these things and then, depending on the result, pass the execution to the same method in a linked RealSubject object.
(self)
| 61 | self._real_subject = real_subject |
| 62 | |
| 63 | def request(self) -> None: |
| 64 | """ |
| 65 | EN: The most common applications of the Proxy pattern are lazy loading, |
| 66 | caching, controlling the access, logging, etc. A Proxy can perform one |
| 67 | of these things and then, depending on the result, pass the execution to |
| 68 | the same method in a linked RealSubject object. |
| 69 | |
| 70 | RU: Наиболее распространёнными областями применения паттерна Заместитель |
| 71 | являются ленивая загрузка, кэширование, контроль доступа, ведение |
| 72 | журнала и т.д. Заместитель может выполнить одну из этих задач, а затем, |
| 73 | в зависимости от результата, передать выполнение одноимённому методу в |
| 74 | связанном объекте класса Реального Субъекта. |
| 75 | """ |
| 76 | |
| 77 | if self.check_access(): |
| 78 | self._real_subject.request() |
| 79 | self.log_access() |
| 80 | |
| 81 | def check_access(self) -> bool: |
| 82 | print("Proxy: Checking access prior to firing a real request.") |
no test coverage detected