-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.py
52 lines (42 loc) · 1.2 KB
/
base.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
"""
Base classes (ABC interfaces) file to make contract with inherits for implementing
necessary methods.
"""
from abc import ABC, abstractmethod
from pony.orm import db_session
from pony.orm.core import EntityMeta
from hashmap import HashMap
class BaseScreen(ABC):
"""
Base screen handler encapsulation class. Methods are to be implemented.
There is no instance methods because objects are not created.
Just encapsulates screen logic.
"""
@classmethod
@abstractmethod
def on_input(cls, hashMap: HashMap, _files=None, _data=None) -> HashMap:
"""Input event handler."""
pass
@classmethod
@abstractmethod
def on_start(cls, hashMap: HashMap, _files=None, _data=None) -> HashMap:
"""Start scree event handler."""
pass
class BaseRepository(ABC):
"""
Base repository class. Defines the simplest data access operations.
"""
entity: EntityMeta
@classmethod
@abstractmethod
def create(cls, bird_id: str):
pass
@classmethod
@db_session
def all(cls):
return cls.entity.select()
@classmethod
@db_session
def get(cls, id_: str):
obj = cls.entity.get(id=id_)
return obj