Exemplo n.º 1
0
class URIMapper:
    def __init__(self):
        self.dict = Dictionary()
        self.authen = Authentication()
        self.course = Course()
        self.error = Error()
    
    def execute(self, environ):
        path = environ['PATH_INFO']
        
        #----- dictionary group -----
        if path.startswith('/lookup:'):
            return self.dict.lookup(environ)   
        
        #----- authentication group -----
        elif path.startswith('/register:'):
            return self.authen.register(environ)
        elif path.startswith('/login:'******'/logout:'):
            return self.authen.logout(environ)
        
        #----- learning group -----
        elif path.startswith('/levels:'):
            return self.course.levels(environ)
        elif path.startswith('/lessons:'):
            return self.course.lessons(environ)
        elif path.startswith('/listen:'):
            return self.course.listen(environ)    
        
        else:
            return self.error.bad_request()
Exemplo n.º 2
0
 def __init__(self):
     self.dict = Dictionary()
     self.authen = Authentication()
     self.course = Course()
     self.error = Error()