Example #1
0
File: main.py Project: lzimm/360io
    def locateChild(self, req, segs):
        name = segs[0]

        self.logicpath = ".".join([self.logicpath, name])
        self.viewpath = ".".join([self.viewpath, name])

        if name == "" and len(segs) == 1:
            return self, server.StopTraversal
        elif name not in self.view:
            try:
                self.view[name] = {"__val__": import_tmpl(self.viewpath)}
                self.view = self.view[name]

                try:
                    if type(self.logic) is not type([]):
                        self.logic[name] = {"__val__": import_mod(self.logicpath)}
                        self.logic = self.logic[name]
                except:
                    self.logic = [self.logic]
            except:
                return self, server.StopTraversal
        else:
            self.view = self.view[name]
            try:
                if type(self.logic) is not type([]):
                    self.logic = self.logic[name]
            except:
                self.logic = self.logic
        return self, segs[1:]
Example #2
0
File: main.py Project: lzimm/360io
    def locateChild(self, req, segs):
        for binding in middleware_bindings:
            binding(req)

        try:
            [self.mode, name] = segs[0].split("-")
        except:
            name = segs[0]

        if name == "" and len(segs) == 1:
            return self, server.StopTraversal
        if os.path.isfile(os.path.join(self.path, name)):
            return IO360HTTPStatic(self, os.path.join(self.path, name)), []
        elif os.path.exists(os.path.join(self.path, name)):
            return IO360HTTPStatic(self, os.path.join(self.path, name)), segs[1:]
        else:
            logicpath = ".".join([self.logic_mod, name])

            if name not in view_tree:
                try:
                    try:
                        logic_tree[name] = {"__val__": import_mod(logicpath)}
                    except:
                        pass

                    view_tree[name] = {"__val__": import_tmpl(name)}
                except:
                    return self, server.StopTraversal

            return IO360HTTPView(self, name, view_tree[name], logicpath, logic_tree[name], self.mode), segs[1:]
Example #3
0
File: main.py Project: lzimm/360io
    def locateChild(self, req, segs):
        name = segs[0]

        self.logicpath = '.'.join([self.logicpath, name])
        self.viewpath = '.'.join([self.viewpath, name])

        if name == '' and len(segs) == 1:
            return self, server.StopTraversal
        elif name not in self.view:
            try:
                self.view[name] = {'__val__': import_tmpl(self.viewpath)}
                self.view = self.view[name]

                try:
                    if type(self.logic) is not type([]):
                        self.logic[name] = {
                            '__val__': import_mod(self.logicpath)
                        }
                        self.logic = self.logic[name]
                except:
                    self.logic = [self.logic]
            except:
                return self, server.StopTraversal
        else:
            self.view = self.view[name]
            try:
                if type(self.logic) is not type([]):
                    self.logic = self.logic[name]
            except:
                self.logic = self.logic
        return self, segs[1:]
Example #4
0
File: main.py Project: lzimm/360io
    def locateChild(self, req, segs):
        for binding in middleware_bindings:
            binding(req)

        try:
            [self.mode, name] = segs[0].split('-')
        except:
            name = segs[0]

        if name == '' and len(segs) == 1:
            return self, server.StopTraversal
        if os.path.isfile(os.path.join(self.path, name)):
            return IO360HTTPStatic(self, os.path.join(self.path, name)), []
        elif os.path.exists(os.path.join(self.path, name)):
            return IO360HTTPStatic(self, os.path.join(self.path,
                                                      name)), segs[1:]
        else:
            logicpath = '.'.join([self.logic_mod, name])

            if name not in view_tree:
                try:
                    try:
                        logic_tree[name] = {'__val__': import_mod(logicpath)}
                    except:
                        pass

                    view_tree[name] = {'__val__': import_tmpl(name)}
                except:
                    return self, server.StopTraversal

            return IO360HTTPView(self, name, view_tree[name], logicpath,
                                 logic_tree[name], self.mode), segs[1:]
Example #5
0
File: main.py Project: lzimm/360io
    def __init__(self, logic_mod, path, mode="http"):
        self.logic_mod = logic_mod
        self.path = path
        self.mode = mode

        if "__val__" not in view_tree:
            logic_tree["__val__"] = import_mod(".".join([self.logic_mod, "index"]))
            view_tree["__val__"] = import_tmpl("index")
Example #6
0
File: main.py Project: lzimm/360io
    def __init__(self, logic_mod, path, mode='http'):
        self.logic_mod = logic_mod
        self.path = path
        self.mode = mode

        if '__val__' not in view_tree:
            logic_tree['__val__'] = import_mod('.'.join(
                [self.logic_mod, 'index']))
            view_tree['__val__'] = import_tmpl('index')