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


Python Cache.drop方法代码示例

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


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

示例1: test_0020_pickling

# 需要导入模块: from trytond.cache import Cache [as 别名]
# 或者: from trytond.cache.Cache import drop [as 别名]
    def test_0020_pickling(self):
        '''
        Test if the lazy rendering object can be pickled and rendered
        with a totally different context (when no application, request
        or transaction bound objects are present).
        '''
        with Transaction().start(DB_NAME, USER, CONTEXT) as txn:
            self.setup_defaults()
            app = self.get_app()

            with app.test_request_context('/'):
                response = render_template(
                    'tests/test-changing-context.html',
                    variable="a"
                )
                self.assertEqual(response, 'a')
                pickled_response = pickle.dumps(response)

            txn.rollback()
            # Drop the cache as the transaction is rollbacked
            Cache.drop(DB_NAME)

        with Transaction().start(DB_NAME, USER, CONTEXT) as txn:
            self.setup_defaults()
            app = self.get_app()

            with app.test_request_context('/'):
                response = pickle.loads(pickled_response)
                self.assertEqual(response, 'a')

            txn.rollback()
            # Drop the cache as the transaction is rollbacked
            Cache.drop(DB_NAME)
开发者ID:fulfilio,项目名称:nereid,代码行数:35,代码来源:test_templates.py

示例2: test_0040_inheritance

# 需要导入模块: from trytond.cache import Cache [as 别名]
# 或者: from trytond.cache.Cache import drop [as 别名]
    def test_0040_inheritance(self):
        '''Test if templates are read in the order of the tryton
        module dependency graph. To test this we install the test
        module now and then try to load a template which is different
        with the test module.
        '''
        trytond.tests.test_tryton.install_module('nereid_test')

        with Transaction().start(DB_NAME, USER, CONTEXT) as txn:  # noqa
            # Add nereid_test also to list of modules installed so
            # that it is also added to the templates path

            self.setup_defaults()
            app = self.get_app()

            self.assertEqual(len(app.jinja_loader.loaders), 3)

            with app.test_request_context('/'):
                self.assertEqual(
                    render_template('tests/from-module.html'),
                    'from-nereid-test-module'
                )

            txn.rollback()
            Cache.drop(DB_NAME)
开发者ID:fulfilio,项目名称:nereid,代码行数:27,代码来源:test_templates.py

示例3: wrapper

# 需要导入模块: from trytond.cache import Cache [as 别名]
# 或者: from trytond.cache.Cache import drop [as 别名]
 def wrapper(*args, **kwargs):
     transaction = Transaction()
     with transaction.start(DB_NAME, user, context=context):
         result = func(*args, **kwargs)
         transaction.cursor.rollback()
         # Drop the cache as the transaction is rollbacked
         Cache.drop(DB_NAME)
         return result
开发者ID:kret0s,项目名称:tryton3_8,代码行数:10,代码来源:test_tryton.py

示例4: test_0040_headers

# 需要导入模块: from trytond.cache import Cache [as 别名]
# 或者: from trytond.cache.Cache import drop [as 别名]
    def test_0040_headers(self):
        '''
        Change registrations headers and check
        '''
        trytond.tests.test_tryton.install_module('nereid_test')
        with Transaction().start(DB_NAME, USER, CONTEXT) as txn:
            self.setup_defaults()
            app = self.get_app()

            with app.test_client() as c:
                response = c.get('/test-lazy-renderer')
                self.assertEqual(response.headers['X-Test-Header'], 'TestValue')
                self.assertEqual(response.status_code, 201)

            txn.rollback()
            # Drop the cache as the transaction is rollbacked
            Cache.drop(DB_NAME)
开发者ID:fulfilio,项目名称:nereid,代码行数:19,代码来源:test_templates.py

示例5: drop

# 需要导入模块: from trytond.cache import Cache [as 别名]
# 或者: from trytond.cache.Cache import drop [as 别名]
def drop(request, database_name, password):
    Database = backend.get('Database')
    security.check_super(password)
    database = Database(database_name)
    database.close()
    # Sleep to let connections close
    time.sleep(1)

    with Transaction().start(None, 0, close=True, autocommit=True) \
            as transaction:
        try:
            database.drop(transaction.connection, database_name)
        except Exception:
            logger.error('DROP DB: %s failed', database_name, exc_info=True)
            raise
        else:
            logger.info('DROP DB: %s', database_name)
            Pool.stop(database_name)
            Cache.drop(database_name)
    return True
开发者ID:coopengo,项目名称:trytond,代码行数:22,代码来源:dispatcher.py

示例6: transaction

# 需要导入模块: from trytond.cache import Cache [as 别名]
# 或者: from trytond.cache.Cache import drop [as 别名]
def transaction(request):
    """Yields transaction with installed module.
    """

    # Importing transaction directly causes cyclic dependency in 3.6
    from trytond.tests.test_tryton import USER, CONTEXT, DB_NAME, POOL
    from trytond.tools.singleton import Singleton  # noqa
    from trytond.transaction import Transaction
    from trytond.cache import Cache

    # Inject helper functions in instance on which test function was collected.
    request.instance.POOL = POOL
    request.instance.USER = USER
    request.instance.CONTEXT = CONTEXT
    request.instance.DB_NAME = DB_NAME

    transaction = Transaction()

    with transaction.start(DB_NAME, USER, context=CONTEXT) as txn:
        yield txn
        transaction.rollback()
        Cache.drop(DB_NAME)
开发者ID:fulfilio,项目名称:trytond-payment-gateway-stripe,代码行数:24,代码来源:conftest.py

示例7: threaded_send_email

# 需要导入模块: from trytond.cache import Cache [as 别名]
# 或者: from trytond.cache.Cache import drop [as 别名]
        def threaded_send_email(email, smtp_server):
            """
            A new threaded email sender. This is required because there is
            no transaction in the new thread that is spawned and sendemail
            tries to create a new cursor from an existing transaction.

            So create the new transaction here, refresh the active record
            objects and call sendmail like the cron would have
            """
            with Transaction().start(DB_NAME, USER, context=CONTEXT):
                # email active record is from old transaction, so referesh it.
                email = EmailQueue(email.id)

                database = backend.get('database')

                try:
                    # Now send the email
                    email.send(smtp_server)
                except database.DatabaseOperationalError:
                    # This specific email could not be sent because of a
                    # transaction serialization error
                    searialization_error_q.put(email.id)
                finally:
                    Cache.drop(DB_NAME)
开发者ID:fulfilio,项目名称:email-queue,代码行数:26,代码来源:test_email_queue.py


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