Exemple #1
0
    def get_remote_repo(my):
        # remote repo does not make sense in batch mode
        if Environment.get_app_server() == 'batch':
            return

        remote_repos = Container.get("remote_repos")
        if remote_repos == None:
            search = Search("sthpw/remote_repo")
            remote_repos = search.get_sobjects()
            Container.put("remote_repos", remote_repos)

        # TODO: Get this function out of this class
        # THIS function requires the web
        from pyasm.web import WebContainer
        web = WebContainer.get_web()
        if not web:
            return None

        # if a login name is found, use that instead of doing the more 
        # stringent IP match
        current_user = Environment.get_user_name()
        simple_remote_repo = RemoteRepo.get_by_login(current_user)
        if simple_remote_repo:
            return simple_remote_repo

        src_ip = web.get_request_host()
        if not src_ip:
            return

        for remote_repo in remote_repos:
            tgt_ip  = remote_repo.get_value("ip_address")
            mask = remote_repo.get_value("ip_mask")

            if Common.match_ip(src_ip, tgt_ip, mask):
                return remote_repo

        return None
Exemple #2
0
    def get_remote_repo(self):
        # remote repo does not make sense in batch mode
        if Environment.get_app_server() == 'batch':
            return

        remote_repos = Container.get("remote_repos")
        if remote_repos == None:
            search = Search("sthpw/remote_repo")
            remote_repos = search.get_sobjects()
            Container.put("remote_repos", remote_repos)

        # TODO: Get this function out of this class
        # THIS function requires the web
        from pyasm.web import WebContainer
        web = WebContainer.get_web()
        if not web:
            return None

        # if a login name is found, use that instead of doing the more 
        # stringent IP match
        current_user = Environment.get_user_name()
        simple_remote_repo = RemoteRepo.get_by_login(current_user)
        if simple_remote_repo:
            return simple_remote_repo

        src_ip = web.get_request_host()
        if not src_ip:
            return

        for remote_repo in remote_repos:
            tgt_ip  = remote_repo.get_value("ip_address")
            mask = remote_repo.get_value("ip_mask")

            if Common.match_ip(src_ip, tgt_ip, mask):
                return remote_repo

        return None