-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathController.py
More file actions
40 lines (32 loc) · 1.09 KB
/
Controller.py
File metadata and controls
40 lines (32 loc) · 1.09 KB
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
import os
import importlib
from config import APP_PATH
import abc
"""
Responsible for the communication between views and models in addiction to
being responsible for the behavior of the program.
"""
class Controller(metaclass=abc.ABCMeta):
#-----------------------------------------------------------------------
# Methods
#-----------------------------------------------------------------------
"""
Executes controller and associated view with it.
"""
@abc.abstractmethod
def main(self):
return
"""
Given a view name, return an instance of it
@param viewName:string View to be opened
"""
def loadView(self, viewName):
response = None
# Set view name
viewName = viewName[0].upper()+viewName[1:]+"View"
# Check if file exists
if os.path.exists(APP_PATH+"/views/"+viewName+".py"):
module = importlib.import_module("views."+viewName)
class_ = getattr(module, viewName)
response = class_(self)
return response