Exemplo n.º 1
0
def dispatch_request(path_info, req, env):
    """Main entry point for the Trac web interface."""

    # Re-parse the configuration file if it changed since the last the time it
    # was parsed
    env.config.parse_if_needed()

    base_url = env.config.get('trac', 'base_url')
    if not base_url:
        base_url = absolute_url(req)
    req.base_url = base_url
    req.path_info = path_info

    env.href = Href(req.cgi_location)
    env.abs_href = Href(req.base_url)

    db = env.get_db_cnx()
    try:
        try:
            dispatcher = RequestDispatcher(env)
            dispatcher.dispatch(req)
        except RequestDone:
            pass
    finally:
        db.close()
Exemplo n.º 2
0
 def test_absolute_url_https_nondefaultport(self):
     req = Mock(scheme='https',
                server_name='example.org',
                server_port=8443,
                get_header=lambda x: None)
     url = absolute_url(req, '/trac')
     self.assertEqual('https://example.org:8443/trac', url)
Exemplo n.º 3
0
 def test_absolute_url(self):
     req = Mock(scheme='http',
                server_name='example.org',
                server_port=None,
                get_header=lambda x: None)
     url = absolute_url(req, '/trac')
     self.assertEqual('http://example.org/trac', url)
Exemplo n.º 4
0
 def test_absolute_url_proxy(self):
     headers = {'X-Forwarded-Host': 'example.org'}
     req = Mock(scheme='http',
                server_name='some.proxy',
                server_port=None,
                get_header=lambda x: headers.get(x))
     url = absolute_url(req, '/trac')
     self.assertEqual('http://example.org/trac', url)
Exemplo n.º 5
0
 def test_absolute_url_https_host(self):
     headers = {'Host': 'example.org'}
     req = Mock(scheme='https',
                server_name='localhost',
                server_port=8443,
                get_header=lambda x: headers.get(x))
     url = absolute_url(req, '/trac')
     self.assertEqual('https://example.org/trac', url)