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


Python AssetsBundle.css方法代码示例

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


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

示例1: test_09_paginated_css_access

# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import css [as 别名]
    def test_09_paginated_css_access(self):
        """ Checks that the bundle's cache is working, i.e. that a bundle creates only enough
        ir.attachment records when rendered multiple times.
        """
        bundle0 = AssetsBundle(self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=1)
        bundle0.css()

        self.assertEquals(len(self._any_ira_for_bundle('css')), 3)

        version0 = bundle0.version
        ira0 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('css')[0])
        date0 = ira0.create_date
        ira1 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('css')[1])
        date1 = ira1.create_date
        ira2 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('css')[2])
        date2 = ira2.create_date

        bundle1 = AssetsBundle(self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=1)
        bundle1.css()

        self.assertEquals(len(self._any_ira_for_bundle('css')), 3)

        version1 = bundle1.version
        ira3 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('css')[0])
        date3 = ira1.create_date
        ira4 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('css')[1])
        date4 = ira1.create_date
        ira5 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('css')[2])
        date5 = ira1.create_date

        self.assertEquals(version0, version1)
        self.assertEquals(date0, date3)
        self.assertEquals(date1, date4)
        self.assertEquals(date2, date5)
开发者ID:AlexM-H,项目名称:odoo,代码行数:36,代码来源:test_assetsbundle.py

示例2: test_10_paginated_css_date_invalidation

# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import css [as 别名]
    def test_10_paginated_css_date_invalidation(self):
        """ Checks that a bundle is invalidated when one of its assets' modification date is changed.
        """
        bundle0 = AssetsBundle(
            self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=1
        )
        bundle0.css()
        last_modified0 = bundle0.last_modified
        version0 = bundle0.version

        path = get_resource_path("test_assetsbundle", "static", "src", "css", "test_cssfile1.css")
        utime(path, None)  # touch

        bundle1 = AssetsBundle(
            self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=1
        )
        bundle1.css()
        last_modified1 = bundle1.last_modified
        version1 = bundle1.version

        self.assertNotEquals(last_modified0, last_modified1)
        self.assertNotEquals(version0, version1)

        # check if the previous attachment is correctly cleaned
        self.assertEquals(len(self._any_ira_for_bundle("css")), 3)
开发者ID:Padmahas,项目名称:odoo,代码行数:27,代码来源:test_assetsbundle.py

示例3: test_11_paginated_css_content_invalidation

# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import css [as 别名]
    def test_11_paginated_css_content_invalidation(self):
        """ Checks that a bundle is invalidated when its content is modified by adding a file to
        source.
        """
        bundle0 = AssetsBundle(
            self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=1
        )
        bundle0.css()
        html0 = bundle0.html
        version0 = bundle0.version

        self.assertEquals(len(self._any_ira_for_bundle("css")), 3)

        view_arch = """
        <data>
            <xpath expr="." position="inside">
                <link rel="stylesheet" href="/test_assetsbundle/static/src/css/test_cssfile2.css"/>
            </xpath>
        </data>
        """
        bundle_id = self.browse_ref(self.cssbundle_xmlid).id
        newid = self.registry["ir.ui.view"].create(
            self.cr,
            self.uid,
            {"name": "test bundle inheritance", "type": "qweb", "arch": view_arch, "inherit_id": bundle_id},
        )

        bundle1 = AssetsBundle(
            self.cssbundle_xmlid,
            cr=self.cr,
            uid=self.uid,
            context={"check_view_ids": [newid]},
            registry=self.registry,
            max_css_rules=1,
        )
        bundle1.css()
        html1 = bundle1.html
        version1 = bundle1.version

        self.assertNotEquals(html0, html1)
        self.assertNotEquals(version0, version1)

        # check if the previous attachment are correctly cleaned
        self.assertEquals(len(self._any_ira_for_bundle("css")), 4)
开发者ID:Padmahas,项目名称:odoo,代码行数:46,代码来源:test_assetsbundle.py

示例4: test_10_paginated_css_date_invalidation

# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import css [as 别名]
    def test_10_paginated_css_date_invalidation(self):
        """ Checks that a bundle is invalidated when one of its assets' modification date is changed.
        """
        bundle0 = AssetsBundle(self.cssbundle_xmlid, env=self.env, max_css_rules=1)
        bundle0.css()
        last_modified0 = bundle0.last_modified
        version0 = bundle0.version

        path = get_resource_path('test_assetsbundle', 'static', 'src', 'css', 'test_cssfile1.css')
        utime(path, None)  # touch

        bundle1 = AssetsBundle(self.cssbundle_xmlid, env=self.env, max_css_rules=1)
        bundle1.css()
        last_modified1 = bundle1.last_modified
        version1 = bundle1.version

        self.assertNotEquals(last_modified0, last_modified1)
        self.assertNotEquals(version0, version1)

        # check if the previous attachment is correctly cleaned
        self.assertEquals(len(self._any_ira_for_bundle('css')), 3)
开发者ID:474416133,项目名称:odoo,代码行数:23,代码来源:test_assetsbundle.py

示例5: test_11_paginated_css_content_invalidation

# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import css [as 别名]
    def test_11_paginated_css_content_invalidation(self):
        """ Checks that a bundle is invalidated when its content is modified by adding a file to
        source.
        """
        bundle0 = AssetsBundle(self.cssbundle_xmlid, env=self.env, max_css_rules=1)
        bundle0.css()
        html0 = bundle0.html
        version0 = bundle0.version

        self.assertEquals(len(self._any_ira_for_bundle('css')), 3)

        view_arch = """
        <data>
            <xpath expr="." position="inside">
                <link rel="stylesheet" href="/test_assetsbundle/static/src/css/test_cssfile2.css"/>
            </xpath>
        </data>
        """
        bundle_id = self.browse_ref(self.cssbundle_xmlid).id
        newid = self.registry['ir.ui.view'].create(self.cr, self.uid, {
            'name': 'test bundle inheritance',
            'type': 'qweb',
            'arch': view_arch,
            'inherit_id': bundle_id,
        })

        bundle1 = AssetsBundle(self.cssbundle_xmlid, env=self.env(context={'check_view_ids': [newid]}), max_css_rules=1)
        bundle1.css()
        html1 = bundle1.html
        version1 = bundle1.version

        self.assertNotEquals(html0, html1)
        self.assertNotEquals(version0, version1)

        # check if the previous attachment are correctly cleaned
        self.assertEquals(len(self._any_ira_for_bundle('css')), 4)
开发者ID:474416133,项目名称:odoo,代码行数:38,代码来源:test_assetsbundle.py

示例6: TestJavascriptAssetsBundle

# 需要导入模块: from openerp.addons.base.ir.ir_qweb import AssetsBundle [as 别名]
# 或者: from openerp.addons.base.ir.ir_qweb.AssetsBundle import css [as 别名]
class TestJavascriptAssetsBundle(TransactionCase):
    def setUp(self):
        super(TestJavascriptAssetsBundle, self).setUp()
        self.jsbundle_xmlid = 'test_assetsbundle.bundle1'
        self.cssbundle_xmlid = 'test_assetsbundle.bundle2'

    def _any_ira_for_bundle(self, type):
        """ Returns all ir.attachments associated to a bundle, regardless of the verion.
        """
        bundle = self.jsbundle_xmlid if type == 'js' else self.cssbundle_xmlid
        return self.registry['ir.attachment'].search(self.cr, self.uid,[
            ('url', '=like', '/web/content/%-%/{0}%.{1}'.format(bundle, type))
        ])

    def test_01_generation(self):
        """ Checks that a bundle creates an ir.attachment record when its `js` method is called
        for the first time.
        """
        self.bundle = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)

        # there shouldn't be any attachment associated to this bundle
        self.assertEquals(len(self._any_ira_for_bundle('js')), 0)
        self.assertEquals(len(self.bundle.get_attachments('js')), 0)

        # trigger the first generation and, thus, the first save in database
        self.bundle.js()

        # there should be one attachment associated to this bundle
        self.assertEquals(len(self._any_ira_for_bundle('js')), 1)
        self.assertEquals(len(self.bundle.get_attachments('js')), 1)

    def test_02_access(self):
        """ Checks that the bundle's cache is working, i.e. that the bundle creates only one
        ir.attachment record when rendered multiple times.
        """
        bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
        bundle0.js()

        self.assertEquals(len(self._any_ira_for_bundle('js')), 1)

        version0 = bundle0.version
        ira0 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('js')[0])
        date0 = ira0.create_date

        bundle1 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
        bundle1.js()

        self.assertEquals(len(self._any_ira_for_bundle('js')), 1)

        version1 = bundle1.version
        ira1 = self.registry['ir.attachment'].browse(self.cr, self.uid, self._any_ira_for_bundle('js')[0])
        date1 = ira1.create_date

        self.assertEquals(version0, version1)
        self.assertEquals(date0, date1)

    def test_03_date_invalidation(self):
        """ Checks that a bundle is invalidated when one of its assets' modification date is changed.
        """
        bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
        bundle0.js()
        last_modified0 = bundle0.last_modified
        version0 = bundle0.version

        path = get_resource_path('test_assetsbundle', 'static', 'src', 'js', 'test_jsfile1.js')
        utime(path, None)  # touch

        bundle1 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
        bundle1.js()
        last_modified1 = bundle1.last_modified
        version1 = bundle1.version
        self.assertNotEquals(last_modified0, last_modified1)
        self.assertNotEquals(version0, version1)

        # check if the previous attachment is correctly cleaned
        self.assertEquals(len(self._any_ira_for_bundle('js')), 1)

    def test_04_content_invalidation(self):
        """ Checks that a bundle is invalidated when its content is modified by adding a file to
        source.
        """
        bundle0 = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
        bundle0.js()
        html0 = bundle0.html
        version0 = bundle0.version

        self.assertEquals(len(self._any_ira_for_bundle('js')), 1)

        view_arch = """
        <data>
            <xpath expr="." position="inside">
                <script type="text/javascript" src="/test_assetsbundle/static/src/js/test_jsfile4.js"/>
            </xpath>
        </data>
        """
        bundle_id = self.browse_ref(self.jsbundle_xmlid).id
        newid = self.registry['ir.ui.view'].create(self.cr, self.uid, {
            'name': 'test bundle inheritance',
            'type': 'qweb',
            'arch': view_arch,
#.........这里部分代码省略.........
开发者ID:AlexM-H,项目名称:odoo,代码行数:103,代码来源:test_assetsbundle.py


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