|
1 | | -from abc import ABC, abstractmethod |
2 | 1 | from typing import Any, Union |
| 2 | +from abc import ABC, abstractmethod |
| 3 | +from pyechonext.request import Request |
| 4 | +from pyechonext.response import Response |
| 5 | + |
| 6 | + |
| 7 | +class BaseModel(ABC): |
| 8 | + """ |
| 9 | + This class describes a base model. |
| 10 | + """ |
| 11 | + |
| 12 | + @abstractmethod |
| 13 | + def create_response(self, *args, **kwargs) -> Response: |
| 14 | + """ |
| 15 | + Creates a response. |
| 16 | +
|
| 17 | + :param args: The arguments |
| 18 | + :type args: list |
| 19 | + :param kwargs: The keywords arguments |
| 20 | + :type kwargs: dictionary |
| 21 | +
|
| 22 | + :returns: response object |
| 23 | + :rtype: Response |
| 24 | + """ |
| 25 | + raise NotImplementedError |
| 26 | + |
| 27 | + @abstractmethod |
| 28 | + def create_request(self, *args, **kwargs) -> Request: |
| 29 | + """ |
| 30 | + Creates a request. |
| 31 | +
|
| 32 | + :param args: The arguments |
| 33 | + :type args: list |
| 34 | + :param kwargs: The keywords arguments |
| 35 | + :type kwargs: dictionary |
| 36 | +
|
| 37 | + :returns: request object |
| 38 | + :rtype: Request |
| 39 | + """ |
| 40 | + raise NotImplementedError |
| 41 | + |
| 42 | + |
| 43 | +class PageModel(BaseView): |
| 44 | + """ |
| 45 | + This class describes a page model. |
| 46 | + """ |
| 47 | + |
| 48 | + def __init__(self, request: Request, response: Response): |
| 49 | + """ |
| 50 | + Constructs a new instance. |
| 51 | +
|
| 52 | + :param request: The request |
| 53 | + :type request: Request |
| 54 | + :param response: The response |
| 55 | + :type response: Response |
| 56 | + """ |
| 57 | + self.request = request |
| 58 | + self.response = response |
| 59 | + |
| 60 | + def create_response(self, *args, **kwargs) -> Response: |
| 61 | + """ |
| 62 | + Creates a response. |
| 63 | +
|
| 64 | + :param args: The arguments |
| 65 | + :type args: list |
| 66 | + :param kwargs: The keywords arguments |
| 67 | + :type kwargs: dictionary |
| 68 | +
|
| 69 | + :returns: response object |
| 70 | + :rtype: Response |
| 71 | + """ |
| 72 | + return Response(*args, **kwargs) |
| 73 | + |
| 74 | + def create_request(self, *args, **kwargs) -> Request: |
| 75 | + """ |
| 76 | + Creates a request. |
3 | 77 |
|
| 78 | + :param args: The arguments |
| 79 | + :type args: list |
| 80 | + :param kwargs: The keywords arguments |
| 81 | + :type kwargs: dictionary |
4 | 82 |
|
5 | | -class BaseView(ABC): |
6 | | - def __init__(self) |
| 83 | + :returns: request object |
| 84 | + :rtype: Request |
| 85 | + """ |
| 86 | + return Request(*args, **kwargs) |
0 commit comments