當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。