-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecorator.py
54 lines (37 loc) · 1.23 KB
/
decorator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from abc import ABC, abstractmethod
class WebPage():
def display(self) -> None:
pass
class BasicWebPage(WebPage):
def __init__(self, html:str, js:str, css:str) -> None:
self.html = html
self.js = js
self.css = css
def display(self) -> None:
# Render HTML & stylesheet + Run js files
print("BasicWebPage: Basic Web Page")
class WebPageDecorator(WebPage):
def __init__(self, webpage:WebPage) -> None:
self.webpage = webpage
def display(self) -> None:
self.webpage.display()
class AuthorizationWebPage(WebPageDecorator):
def __init__(self, decoratedwebpage:WebPage) -> None:
super().__init__(decoratedwebpage)
def authorization(self) -> None:
print("AuthorizationWebPage: authorization")
def display(self) -> None:
super().display()
self.authorization()
class AuthenticationWebPage(WebPageDecorator):
def __init__(self, decoratedwebpage:WebPage) -> None:
super().__init__(decoratedwebpage)
def authentication(self) -> None:
print("AuthenticationWebPage: authentication")
def display(self) -> None:
super().display()
self.authentication()
mypage = BasicWebPage('html', 'css', 'js')
mypage_dec1 = AuthorizationWebPage(mypage)
mypage_dec2 = AuthenticationWebPage(mypage_dec1)
mypage_dec2.display()