Пример #1
0
    def __init__(self, req, options):
        environ = {}
        environ.update(apache.build_cgi_env(req))

        environ['trac.web.frontend'] = 'mod_python'
        environ['trac.web.version'] = version

        if 'TracEnv' in options:
            environ['trac.env_path'] = options['TracEnv']
        if 'TracEnvParentDir' in options:
            environ['trac.env_parent_dir'] = options['TracEnvParentDir']
        if 'TracEnvIndexTemplate' in options:
            environ['trac.env_index_template'] = options[
                'TracEnvIndexTemplate']
        if 'TracTemplateVars' in options:
            environ['trac.template_vars'] = options['TracTemplateVars']
        if 'TracLocale' in options:
            environ['trac.locale'] = options['TracLocale']

        if 'TracUriRoot' in options:
            # Special handling of SCRIPT_NAME/PATH_INFO for mod_python, which
            # tends to get confused for whatever reason
            root_uri = options['TracUriRoot'].rstrip('/')
            request_uri = environ['REQUEST_URI'].split('?', 1)[0]
            if not request_uri.startswith(root_uri):
                raise ValueError('TracUriRoot set to %s but request URL '
                                 'is %s' % (root_uri, request_uri))
            environ['SCRIPT_NAME'] = root_uri
            environ['PATH_INFO'] = urllib.unquote(request_uri[len(root_uri):])

        WSGIGateway.__init__(self, environ, InputWrapper(req),
                             _ErrorsWrapper(lambda x: req.log_error(x)))
        self.req = req
Пример #2
0
    def __init__(self, req, options):
        environ = {}
        environ.update(apache.build_cgi_env(req))

        environ['trac.web.frontend'] = 'mod_python'
        environ['trac.web.version'] = version

        if 'TracEnv' in options:
            environ['trac.env_path'] = options['TracEnv']
        if 'TracEnvParentDir' in options:
            environ['trac.env_parent_dir'] = options['TracEnvParentDir']
        if 'TracEnvIndexTemplate' in options:
            environ['trac.env_index_template'] = options['TracEnvIndexTemplate']
        if 'TracTemplateVars' in options:
            environ['trac.template_vars'] = options['TracTemplateVars']
        if 'TracLocale' in options:
            environ['trac.locale'] = options['TracLocale']

        if 'TracUriRoot' in options:
            # Special handling of SCRIPT_NAME/PATH_INFO for mod_python, which
            # tends to get confused for whatever reason
            root_uri = options['TracUriRoot'].rstrip('/')
            request_uri = environ['REQUEST_URI'].split('?', 1)[0]
            if not request_uri.startswith(root_uri):
                raise ValueError('TracUriRoot set to %s but request URL '
                                 'is %s' % (root_uri, request_uri))
            environ['SCRIPT_NAME'] = root_uri
            environ['PATH_INFO'] = urllib.unquote(request_uri[len(root_uri):])

        WSGIGateway.__init__(self, environ, InputWrapper(req),
                             _ErrorsWrapper(lambda x: req.log_error(x)))
        self.req = req
Пример #3
0
    def __init__(self, req, options):
        environ = {}
        environ.update(apache.build_cgi_env(req))

        environ["trac.web.frontend"] = "mod_python"
        environ["trac.web.version"] = version

        if "TracEnv" in options:
            environ["trac.env_path"] = options["TracEnv"]
        if "TracEnvParentDir" in options:
            environ["trac.env_parent_dir"] = options["TracEnvParentDir"]
        if "TracEnvIndexTemplate" in options:
            environ["trac.env_index_template"] = options["TracEnvIndexTemplate"]
        if "TracTemplateVars" in options:
            environ["trac.template_vars"] = options["TracTemplateVars"]
        if "TracLocale" in options:
            environ["trac.locale"] = options["TracLocale"]

        if "TracUriRoot" in options:
            # Special handling of SCRIPT_NAME/PATH_INFO for mod_python, which
            # tends to get confused for whatever reason
            root_uri = options["TracUriRoot"].rstrip("/")
            request_uri = environ["REQUEST_URI"].split("?", 1)[0]
            if not request_uri.startswith(root_uri):
                raise ValueError("TracUriRoot set to %s but request URL " "is %s" % (root_uri, request_uri))
            environ["SCRIPT_NAME"] = root_uri
            environ["PATH_INFO"] = urllib.unquote(request_uri[len(root_uri) :])

        WSGIGateway.__init__(self, environ, InputWrapper(req), _ErrorsWrapper(lambda x: req.log_error(x)))
        self.req = req
Пример #4
0
 def __init__(self, req, options):
     environ = {}
     environ.update(apache.build_cgi_env(req))
     environ['mod_python.options'] = options
     environ['mod_python.subprocess_env'] = req.subprocess_env
     WSGIGateway.__init__(self, environ, InputWrapper(req),
                          _ErrorsWrapper(lambda x: req.log_error(x)))
     self.req = req
 def __init__(self, req, options):
     environ = {}
     environ.update(apache.build_cgi_env(req))
     environ['mod_python.options'] = options
     environ['mod_python.subprocess_env'] = req.subprocess_env
     WSGIGateway.__init__(self, environ, InputWrapper(req),
                          _ErrorsWrapper(lambda x: req.log_error(x)))
     self.req = req
Пример #6
0
	def __init__( self, connection, environ ):

		environ[ 'trac.web.frontend' ] = 'zimr'
		environ[ 'trac.web.version' ] = '0.1'
		environ[ 'trac.base_url' ] = connection.website.protocol + connection.website.url
		for key in connection.request.headers.keys():
			environ[ "HTTP_" + key.upper() ] = connection.request.headers[ key ]
		#environ[ 'SERVER_PORT' ] = 80
		environ[ 'SERVER_NAME' ] = "localhost"
		environ[ 'REQUEST_METHOD' ] = "get"
		environ[ 'REQUEST_URI' ] = connection.request.url
		environ[ 'QUERY_STRING' ] = "&".join( [ "%s=%s" % ( key, urllib.quote( val ) ) for key, val in connection.request.params.items() ] )
		environ[ 'PATH_INFO' ] = "/" + connection.request.url
		environ[ 'SCRIPT_NAME' ] = "" #root uri
		#environ[ 'SERVER_PROTOCOL' ] = connection.website.protocol
		environ[ 'REQUEST_METHOD' ] = connection.request.method
		#environ['REMOTE_HOST'] = host
		#environ['REMOTE_ADDR'] = self.client_address[0]
		environ[ 'CONTENT_TYPE' ] = connection.request.headers[ 'Content-Type' ]
		environ[ 'CONTENT_LENGTH' ] = connection.request.headers[ 'Content-Length' ]

		WSGIGateway.__init__( self, environ, InputWrapper( connection ),
							 _ErrorsWrapper( lambda x: req.log_error( x ) ) )
		self.connection = connection
Пример #7
0
 def __init__(self):
     WSGIGateway.__init__(self, dict(os.environ))
Пример #8
0
 def __init__(self):
     WSGIGateway.__init__(self, dict(os.environ))