コード例 #1
0
ファイル: tests.py プロジェクト: andreypopp/routr
    def test_simple(self):
        def f(user, a, request):
            pass
        self.assertEqual(
            inject_args(f, ['a'], user='******', request='request'),
            ['user', 'a', 'request'])

        def f(a, request):
            pass
        self.assertEqual(
            inject_args(f, ['a'], user='******', request='request'),
            ['a', 'request'])

        def f(user, a):
            pass
        self.assertEqual(
            inject_args(f, ['a'], user='******', request='request'),
            ['user', 'a'])
コード例 #2
0
ファイル: tests.py プロジェクト: pombredanne/routr
    def test_simple(self):
        def f(user, a, request):
            pass

        self.assertEqual(inject_args(f, ['a'], user='******', request='request'),
                         ['user', 'a', 'request'])

        def f(a, request):
            pass

        self.assertEqual(inject_args(f, ['a'], user='******', request='request'),
                         ['a', 'request'])

        def f(user, a):
            pass

        self.assertEqual(inject_args(f, ['a'], user='******', request='request'),
                         ['user', 'a'])
コード例 #3
0
ファイル: app.py プロジェクト: andreypopp/rororo
def application(environ, start_response):
    request = Request(environ)

    try:
        trace = routes(request)
        view = trace.target
        args, kwargs = trace.args, trace.kwargs
        args = inject_args(view, args, request=request)
        response = view(*args, **kwargs)
        if not isinstance(response, Response):
            response = process_renderer(trace, response)
    except NoMatchFound, e:
        response = e.response