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