1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/royalherald/request.py

25 lines
716 B
Python
Raw Normal View History

2019-10-15 09:07:04 +00:00
class Request:
"""A request sent from a :py:class:`Link` to another.
It contains the name of the requested handler, in addition to the data."""
def __init__(self, handler: str, data: dict):
super().__init__()
self.handler: str = handler
self.data: dict = data
def to_dict(self):
return self.__dict__
2019-10-20 16:12:12 +00:00
@classmethod
def from_dict(cls, d: dict):
return cls(**d)
2019-10-15 09:07:04 +00:00
def __eq__(self, other):
2019-10-20 16:12:12 +00:00
if isinstance(other, self.__class__):
2019-10-15 09:07:04 +00:00
return self.handler == other.handler and self.data == other.data
return False
def __repr__(self):
return f"{self.__class__.__qualname__}(handler={self.handler}, data={self.data})"