当前位置: 首页>>代码示例>>Python>>正文


Python _app_ctx_stack.top方法代码示例

本文整理汇总了Python中flask._app_ctx_stack.top方法的典型用法代码示例。如果您正苦于以下问题:Python _app_ctx_stack.top方法的具体用法?Python _app_ctx_stack.top怎么用?Python _app_ctx_stack.top使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask._app_ctx_stack的用法示例。


在下文中一共展示了_app_ctx_stack.top方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _contextualise_connection

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def _contextualise_connection(self, connection):
        """
        Add a connection to the appcontext so it can be freed/unbound at
        a later time if an exception occured and it was not freed.

        Args:
            connection (ldap3.Connection): Connection to add to the appcontext

        """

        ctx = stack.top
        if ctx is not None:
            if not hasattr(ctx, "ldap3_manager_connections"):
                ctx.ldap3_manager_connections = [connection]
            else:
                ctx.ldap3_manager_connections.append(connection) 
开发者ID:nickw444,项目名称:flask-ldap3-login,代码行数:18,代码来源:__init__.py

示例2: getContacts

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def getContacts(self, num=1, columns=[], cardCode=None, contact={}):
        """Retrieve contacts under a business partner by CardCode from SAP B1.
        """
        cols = '*'
        if len(columns) > 0:
            cols = " ,".join(columns)

        sql = """SELECT top {0} {1} FROM dbo.OCPR""".format(num, cols)
        params = dict({(k, 'null' if v is None else v) for k, v in contact.items()})
        params['cardcode'] = cardCode
        sql = sql + ' WHERE ' + " AND ".join(["{0} = %({1})s".format(k, k) for k in params.keys()])

        self.cursorAdaptor.sqlSrvCursor.execute(sql, params)
        contacts = []
        for row in self.cursorAdaptor.sqlSrvCursor:
            contact = {}
            for k, v in row.items():
                value = ''
                if type(v) is datetime.datetime:
                    value = v.strftime("%Y-%m-%d %H:%M:%S")
                elif v is not None:
                    value = str(v)
                contact[k] = value
            contacts.append(contact)
        return contacts 
开发者ID:ideabosque,项目名称:Flask-SAPB1,代码行数:27,代码来源:flask_sapb1.py

示例3: push_ctx

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def push_ctx(app=None):
    """Creates new test context(s) for the given app

    If the app is not None, it overrides any existing app and/or request
    context. In other words, we will use the app that was passed in to create
    a new test request context on the top of the stack. If, however, nothing
    was passed in, we will assume that another app and/or  request context is
    already in place and use that to run the test suite. If no app or request
    context can be found, an AssertionError is emitted to let the user know
    that they must somehow specify an application for testing.

    """
    if app is not None:
        ctx = app.test_request_context()
        ctx.fixtures_request_context = True
        ctx.push()
        if _app_ctx_stack is not None:
            _app_ctx_stack.top.fixtures_app_context = True

    # Make sure that we have an application in the current context
    if (_app_ctx_stack is None or _app_ctx_stack.top is None) and _request_ctx_stack.top is None:
        raise AssertionError('A Flask application must be specified for Fixtures to work.') 
开发者ID:croach,项目名称:Flask-Fixtures,代码行数:24,代码来源:__init__.py

示例4: get_app

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def get_app(self, reference_app=None):
        """Helper method that implements the logic to look up an application."""

        if reference_app is not None:
            return reference_app

        if self.app is not None:
            return self.app

        ctx = stack.top

        if ctx is not None:
            return ctx.app

        raise RuntimeError('Application not registered on Bouncer'
                           ' instance and no application bound'
                           ' to current context') 
开发者ID:bouncer-app,项目名称:flask-bouncer,代码行数:19,代码来源:flask_bouncer.py

示例5: connection

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def connection(self) -> influxdb.InfluxDBClient:
        """
        InfluxDBClient object
        :return:
        """
        ctx = _app_ctx_stack.top
        if ctx is None:
            raise RuntimeError(_app_ctx_err_msg)

        if not hasattr(ctx, "influxdb_db"):
            ctx.influxdb_db = self.connect()

        if ctx.influxdb_db is None:
            raise RuntimeError(_no_influx_msg)

        return ctx.influxdb_db 
开发者ID:btashton,项目名称:flask-influxdb,代码行数:18,代码来源:flask_influxdb.py

示例6: teardown_request

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def teardown_request(self, exception):
        ctx = _ctx_stack.top
        if hasattr(ctx, "mysql_db"):
            ctx.mysql_db.close() 
开发者ID:LuciferJack,项目名称:python-mysql-pool,代码行数:6,代码来源:mysql.py

示例7: get_db

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def get_db(self):
        ctx = _ctx_stack.top
        if ctx is not None:
            if not hasattr(ctx, "mysql_db"):
                ctx.mysql_db = self.connect()
            return ctx.mysql_db 
开发者ID:LuciferJack,项目名称:python-mysql-pool,代码行数:8,代码来源:mysql.py

示例8: request

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def request(self):
        """Local Proxy refering to the request JSON recieved from Dialogflow"""
        return getattr(_app_ctx_stack.top, "_assist_request", None) 
开发者ID:treethought,项目名称:flask-assistant,代码行数:5,代码来源:core.py

示例9: intent

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def intent(self):
        """Local Proxy refering to the name of the intent contained in the Dialogflow request"""
        return getattr(_app_ctx_stack.top, "_assist_intent", None) 
开发者ID:treethought,项目名称:flask-assistant,代码行数:5,代码来源:core.py

示例10: access_token

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def access_token(self):
        """Local proxy referring to the OAuth token for linked accounts."""
        return getattr(_app_ctx_stack.top, "_assist_access_token", None) 
开发者ID:treethought,项目名称:flask-assistant,代码行数:5,代码来源:core.py

示例11: context_in

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def context_in(self):
        """Local Proxy refering to context objects contained within current session"""
        return getattr(_app_ctx_stack.top, "_assist_context_in", []) 
开发者ID:treethought,项目名称:flask-assistant,代码行数:5,代码来源:core.py

示例12: context_manager

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def context_manager(self):
        """LocalProxy refering to the app's instance of the  :class: `ContextManager`.

        Interface for adding and accessing contexts and their parameters
        """
        return getattr(
            _app_ctx_stack.top, "_assist_context_manager", ContextManager(self)
        ) 
开发者ID:treethought,项目名称:flask-assistant,代码行数:10,代码来源:core.py

示例13: convert_errors

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def convert_errors(self):
        return getattr(_app_ctx_stack.top, "_assistant_convert_errors", None) 
开发者ID:treethought,项目名称:flask-assistant,代码行数:4,代码来源:core.py

示例14: session_id

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def session_id(self):
        return getattr(_app_ctx_stack.top, "_assist_session_id", None) 
开发者ID:treethought,项目名称:flask-assistant,代码行数:4,代码来源:core.py

示例15: user

# 需要导入模块: from flask import _app_ctx_stack [as 别名]
# 或者: from flask._app_ctx_stack import top [as 别名]
def user(self):
        return getattr(_app_ctx_stack.top, "_assist_user", {}) 
开发者ID:treethought,项目名称:flask-assistant,代码行数:4,代码来源:core.py


注:本文中的flask._app_ctx_stack.top方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。