예제 #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
    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()