コード例 #1
0
 def application(self, environ=None):
     app = self.app
     ctx = local.push(app, environ)
     try:
         if environ is not None:
             ctx.request = app.config['ayame.request'](environ, {})
             ctx._router = app.config['ayame.route.map'].bind(environ)
         yield
     finally:
         local.pop()
コード例 #2
0
ファイル: base.py プロジェクト: hattya/ayame
 def application(self, environ=None):
     app = self.app
     ctx = local.push(app, environ)
     try:
         if environ is not None:
             ctx.request = app.config['ayame.request'](environ, {})
             ctx._router = app.config['ayame.route.map'].bind(environ)
         yield
     finally:
         local.pop()
コード例 #3
0
ファイル: test_local.py プロジェクト: movermeyer/ayame
    def test_push(self):
        ctx = local.push(0, 1)
        self.assert_equal(ctx.app, 0)
        self.assert_equal(ctx.environ, 1)
        self.assert_is_none(ctx.request)
        self.assert_is_none(ctx._router)

        self.assert_is(local.context(), ctx)
        self.assert_is(local.app(), ctx.app)
        self.assert_is(local.pop(), ctx)

        self.assert_is_none(local.pop())

        with self.assert_raises(ayame.AyameError):
            local.context()
        with self.assert_raises(ayame.AyameError):
            local.app()
コード例 #4
0
ファイル: test_local.py プロジェクト: hattya/ayame
    def test_push(self):
        ctx = local.push(0, 1)
        self.assert_equal(ctx.app, 0)
        self.assert_equal(ctx.environ, 1)
        self.assert_is_none(ctx.request)
        self.assert_is_none(ctx._router)

        self.assert_is(local.context(), ctx)
        self.assert_is(local.app(), ctx.app)
        self.assert_is(local.pop(), ctx)

        self.assert_is_none(local.pop())

        with self.assert_raises(ayame.AyameError):
            local.context()
        with self.assert_raises(ayame.AyameError):
            local.app()