teardown_appcontext()

@setupmethod
    def teardown_appcontext(self, f):

        """Registers a function to be called when the application context
        ends.  These functions are typically also called when the request
        context is popped.

        Example::

            ctx = app.app_context()
            ctx.push()
            ...
            ctx.pop()


        When ``ctx.pop()`` is executed in the above example, the teardown
        functions are called just before the app context moves from the
        stack of active contexts.  This becomes relevant if you are using
        such constructs in tests.


        Since a request context typically also manages an application
        context it would also be called when you pop a request context.


        When a teardown function was called because of an exception it will
        be passed an error object.


        .. versionadded:: 0.9
        """

        self.teardown_appcontext_funcs.append(f)

        return f


谷歌翻译结果:

“”注册函数时被调用的应用程序上下文
        结束。这些功能通常也被称为请求时
        弹出上下文。

        例如::

            CTX= app.app_context()
            (ctx.push)
            ...
            (ctx.pop)


        当`` ctx.pop()``在上面的例子中,执行拆机
        函数被调用之前从移动应用程序上下文
        堆叠活性上下文。如果您正在使用,这将成为相关
        这样的结构测试。


        因为请求上下文通常还管理一个应用程序
        情况下,它也被称为当你弹出一个请求上下文。


        因为异常会被称为当拆卸功能
        传递一个错误对象。


        .. versionadded::0.9
        “”“

大概意思应该是你把一个东西加入到context,那么工作完成后你就要把它释放掉。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值