예제 #1
0
 def get_request(self, path, method="GET", body=None, **extra):
     env = StubWSGIRequest(path)
     env['REQUEST_METHOD'] = method
     env['wsgi.input'] = StringIO(body)
     env['HTTP_COOKIE'] = self.cookies.output(header='', sep='; ')
     env.update(extra)
     return Request.from_wsgi(env)
예제 #2
0
 def get_request(self, path, method="GET", body=None, **extra):
     env = StubWSGIRequest(path)
     env["REQUEST_METHOD"] = method
     env["wsgi.input"] = StringIO(body)
     env["HTTP_COOKIE"] = self.cookies.output(header="", sep="; ")
     env.update(extra)
     return Request.from_wsgi(env)
예제 #3
0
 def get_request(self, path, method="GET", body=None,
                 **extra):
     env = StubWSGIRequest(path)
     env['REQUEST_METHOD'] = method
     env['wsgi.input'] = StringIO(body)
     env['HTTP_COOKIE'] = self.cookies.output(header='', sep='; ')
     env.update(extra)
     return Request.from_wsgi(env)
예제 #4
0
 def __call__(self, environ, start_response):
     """WSGI interface.
     """
     request = Request.from_wsgi(environ)  # too big to fail :-/
     response = self.handle_safely(request)
     response.request = request  # Stick this on here at the last minute
     # in order to support close hooks.
     return response(environ, start_response)
예제 #5
0
 def __call__(self, environ, start_response):
     """WSGI interface.
     """
     request = Request.from_wsgi(environ) # too big to fail :-/
     response = self.handle_safely(request)
     response.request = request # Stick this on here at the last minute
                                # in order to support close hooks.
     return response(environ, start_response)
예제 #6
0
 def get_request(self, path, method="GET", body=None,
                 **extra):
     env = StubWSGIRequest(path.encode('utf8'))
     env[b'REQUEST_METHOD'] = method.encode('utf8')
     env[b'wsgi.input'] = StringIO(body)
     env[b'HTTP_COOKIE'] = self.cookies.output(header='', sep='; ').encode('utf8')
     for k,v in extra.items():
         env[k.encode('utf8')] = v.encode('utf8')
     return Request.from_wsgi(env)
예제 #7
0
 def get_request(self, path, method="GET", body=None, **extra):
     env = StubWSGIRequest(path.encode('utf8'))
     env[b'REQUEST_METHOD'] = method.encode('utf8')
     env[b'wsgi.input'] = StringIO(body)
     env[b'HTTP_COOKIE'] = self.cookies.output(header='',
                                               sep='; ').encode('utf8')
     for k, v in extra.items():
         env[k.encode('utf8')] = v.encode('utf8')
     return Request.from_wsgi(env)
예제 #8
0
 def from_fs(cls, fs):
     """Takes a path under ./fsfix using / as the path separator.
     """
     fs = os.sep.join(fs.split('/'))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     c = Configurable.from_argv(['fsfix'])
     c.copy_configuration_to(request)
     request.fs = fs
     request.namespace = {}
     request.website = Stub()
     request.website.template_loader = Stub()
     return request
예제 #9
0
파일: __init__.py 프로젝트: jatr/aspen
 def from_fs(cls, fs):
     """Takes a path under ./fsfix using / as the path separator.
     """
     fs = os.sep.join(fs.split(os.sep))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     website = Configurable.from_argv(['--root', 'fsfix'])
     website.copy_configuration_to(request)
     request.root = join(dirname(__file__), 'fsfix')
     request.fs = fs
     request.namespace = {}
     request.website = website 
     request.website.template_loader = Stub()
     return request
예제 #10
0
파일: __init__.py 프로젝트: jarpineh/aspen
 def from_fs(cls, fs, *a):
     """Takes a path under FSFIX using / as the path separator.
     """
     fs = os.sep.join(fs.split(os.sep))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     website = Configurable.from_argv([ '--www_root', FSFIX
                                      , '--project_root', '.aspen'
                                       ] + list(a))
     request.www_root = os.path.join(os.path.dirname(__file__), FSFIX)
     request.fs = fs
     request.context = {}
     request.website = website 
     request._media_type = None
     return request
예제 #11
0
 def from_fs(cls, fs, *a):
     """Takes a path under FSFIX using / as the path separator.
     """
     fs = os.sep.join(fs.split(os.sep))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     website = Website([ '--www_root', FSFIX
                       , '--project_root', '.aspen'
                        ] + list(a))
     request.www_root = os.path.join(os.path.dirname(__file__), FSFIX)
     request.fs = fs
     request.context = {}
     request.website = website
     request._media_type = None
     return request
예제 #12
0
    def wsgi_app(self, environ, start_response):
        """WSGI interface.

        Wrap this method instead of the website object itself
        when to use WSGI middleware::

            website = Website()
            website.wsgi_app = WSGIMiddleware(website.wsgi_app)

        """
        request = Request.from_wsgi(environ) # too big to fail :-/
        request.website = self
        response = self.handle_safely(request)
        response.request = request # Stick this on here at the last minute
                                   # in order to support close hooks.
        return response(environ, start_response)
예제 #13
0
    def wsgi_app(self, environ, start_response):
        """WSGI interface.

        Wrap this method instead of the website object itself
        when to use WSGI middleware::

            website = Website()
            website.wsgi_app = WSGIMiddleware(website.wsgi_app)

        """
        request = Request.from_wsgi(environ) # too big to fail :-/
        request.website = self
        response = self.handle_safely(request)
        response.request = request # Stick this on here at the last minute
                                   # in order to support close hooks.
        return response(environ, start_response)
예제 #14
0
 def from_fs(cls, fs, *a):
     """Takes a path under FSFIX using / as the path separator.
     """
     fs = os.sep.join(fs.split(os.sep))
     uri_path = fs
     if fs.endswith('.spt'):
         uri_path = fs[:-4]
     request = Request.from_wsgi(StubWSGIRequest(uri_path))
     website = Website([ '--www_root', FSFIX
                       , '--project_root', os.path.join(FSFIX, '.aspen')
                        ] + list(a))
     request.www_root = os.path.join(os.path.dirname(__file__), FSFIX)
     request.fs = fs
     request.context = {}
     request.website = website
     request._media_type = None
     return request
예제 #15
0
 def __call__(cls, path='/'):
     return Request.from_wsgi(StubWSGIRequest(path))
예제 #16
0
파일: website.py 프로젝트: falstaff84/aspen
 def __call__(self, environ, start_response):
     """WSGI interface.
     """
     request = Request.from_wsgi(environ) # too big to fail :-/
     response = self.handle(request)
     return response(environ, start_response)
예제 #17
0
 def __call__(cls, uripath=b'/'):
     typecheck(uripath, str)
     return Request.from_wsgi(StubWSGIRequest(uripath))
예제 #18
0
def parse_environ_into_request(environ):
    return {'request': Request.from_wsgi(environ)}
예제 #19
0
 def __call__(cls, uripath='/'):
     return Request.from_wsgi(StubWSGIRequest(uripath))