示例#1
0
文件: server.py 项目: cordis/spinoff
 def __init__(self, ch, env, start_response, content_type):
     self.ch = ch
     self.env = env
     self._response_started = False
     self._start_response = start_response
     self.content_type = content_type
     self.closed = False
     BaseRequest.__init__(self, env)
示例#2
0
文件: server.py 项目: cordis/spinoff
 def __init__(self, ch, env, start_response, content_type):
     self.ch = ch
     self.env = env
     self._response_started = False
     self._start_response = start_response
     self.content_type = content_type
     self.closed = False
     BaseRequest.__init__(self, env)
示例#3
0
def application(environ, start_response):
    req = BaseRequest(environ)
    if req.method == 'POST':
        resp = view_file(req)
    else:
        resp = upload_file(req)
    return resp(environ, start_response)
示例#4
0
def dispatch_request(environ, start_response):
    """
    A simple dispatch function that (if decorated with responder) 
    is the complete WSGI application that does the template  
    rendering and error handling.
    """
    # first we bind the url map to the current request
    adapter = url_map.bind_to_environ(environ)
    # then we wrap all the calls in a try/except for HTTP exceptions
    try:
        # get the endpoint and the values (variable or parts)
        # of the adapter.  If the match fails it raises a NotFound
        # exception which is a HTTPException which we catch
        endpoint, values = adapter.match()
        
        # create a new request object for the incoming WSGI environ
        request = BaseRequest(environ)
        
        # create an empty response object with the correct mimetype.
        response = BaseResponse(mimetype='text/html')
        
        # get the template and render it. Pass some useful stuff to 
        # the template (request and response objects, the current  
        # url endpoint, the url values and a url_for function which 
        # can be used to generate urls
        template = domain.get_template(endpoint + '.html')
        response.write(template.evoque(
            request=request,
            response=response,
            endpoint=endpoint,
            url_for=lambda e, **v: adapter.build(e, v),
            url_values=values
        ))
        
        # return the response
        return response
    
    except HTTPException as e:
        # if an http exception is caught we can return it as  
        # response because those exceptions render standard error 
        # messages under wsgi
        return e
示例#5
0
 def __init__(self, environ, **kw):
     BaseRequest.__init__(self, environ, kw)
     self.getsession()
     self.implementation = chooser.get(self.session)
 def __init__(self, environ, url_adapter):
     BaseRequest.__init__(self, environ)
     self.url_adapter = url_adapter
     local.request = self
示例#7
0
 def __init__(self, environ):
     BaseRequest.__init__(self, environ)
     self.session = SecureCookie.load_cookie(self, secret_key=SECRET_KEY)
示例#8
0
 def __init__(self, environ):
     BaseRequest.__init__(self, environ)
     self.session = SecureCookie.load_cookie(self, secret_key=SECRET_KEY)
示例#9
0
def application(environ, start_response):
    request = BaseRequest(environ)
    return response('This is a Test.', 'text/plain')
示例#10
0
文件: app.py 项目: zzz-i2p/i2p.www
 def __init__(self, environ):
     BaseRequest.__init__(self, environ)