當前位置: 首頁>>代碼示例>>Python>>正文


Python ir_qweb.AssetsBundle類代碼示例

本文整理匯總了Python中openerp.addons.base.ir.ir_qweb.AssetsBundle的典型用法代碼示例。如果您正苦於以下問題:Python AssetsBundle類的具體用法?Python AssetsBundle怎麽用?Python AssetsBundle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AssetsBundle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _bundle

 def _bundle(self, should_create, should_unlink):
     self.counter.clear()
     files, remains = self.env['ir.qweb']._get_asset_content(self.lessbundle_xmlid, {})
     asset = AssetsBundle(self.lessbundle_xmlid, files, remains, env=self.env)
     asset.to_html(debug='assets')
     self.assertEquals(self.counter['create'], int(should_create))
     self.assertEquals(self.counter['unlink'], int(should_unlink))
開發者ID:0967697922,項目名稱:odoo,代碼行數:7,代碼來源:test_assetsbundle.py

示例2: test_12_paginated_css_debug

    def test_12_paginated_css_debug(self):
        """ Check that a bundle in debug mode outputs non-minified assets.
        """
        debug_bundle = AssetsBundle(self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=1)
        content = debug_bundle.to_html(debug=True)
        # find back one of the original asset file
        self.assertIn('/test_assetsbundle/static/src/css/test_cssfile1.css', content)

        # there shouldn't be any assets created in debug mode
        self.assertEquals(len(self._any_ira_for_bundle('css')), 0)
開發者ID:AlexM-H,項目名稱:odoo,代碼行數:10,代碼來源:test_assetsbundle.py

示例3: test_05_debug

    def test_05_debug(self):
        """ Checks that a bundle rendered in debug mode outputs non-minified assets.
        """
        debug_bundle = AssetsBundle(self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry)
        content = debug_bundle.to_html(debug=True)
        # find back one of the original asset file
        self.assertIn('/test_assetsbundle/static/src/js/test_jsfile1.js', content)

        # there shouldn't be any assets created in debug mode
        self.assertEquals(len(self._any_ira_for_bundle('js')), 0)
開發者ID:AlexM-H,項目名稱:odoo,代碼行數:10,代碼來源:test_assetsbundle.py

示例4: test_08_paginated_css_generation3

 def test_08_paginated_css_generation3(self):
     # self.cssbundle_xlmid contains 3 rules
     self.bundle = AssetsBundle(
         self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=3
     )
     self.bundle.css()
     self.assertEquals(len(self._any_ira_for_bundle("css")), 1)
     self.assertEquals(len(self.bundle.get_attachments("css")), 1)
開發者ID:Padmahas,項目名稱:odoo,代碼行數:8,代碼來源:test_assetsbundle.py

示例5: test_13_paginated_css_order

    def test_13_paginated_css_order(self):
        # self.cssbundle_xlmid contains 3 rules
        self.bundle = AssetsBundle(self.cssbundle_xmlid, env=self.env, max_css_rules=1)
        stylesheets = self.bundle.css()

        self.assertTrue(stylesheets[0].url.endswith('.0.css'))
        self.assertTrue(stylesheets[1].url.endswith('.1.css'))
        self.assertTrue(stylesheets[2].url.endswith('.2.css'))
開發者ID:474416133,項目名稱:odoo,代碼行數:8,代碼來源:test_assetsbundle.py

示例6: test_13_paginated_css_order

    def test_13_paginated_css_order(self):
        # self.cssbundle_xlmid contains 3 rules
        self.bundle = AssetsBundle(self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=1)
        stylesheets = self.bundle.css()

        self.assertTrue(stylesheets[0].url.endswith('.0.css'))
        self.assertTrue(stylesheets[1].url.endswith('.1.css'))
        self.assertTrue(stylesheets[2].url.endswith('.2.css'))
開發者ID:AlexM-H,項目名稱:odoo,代碼行數:8,代碼來源:test_assetsbundle.py

示例7: theme_customize

    def theme_customize(self, enable, disable, get_bundle=False):
        """ enable or Disable lists of ``xml_id`` of the inherit templates
        """
        cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
        view = pool["ir.ui.view"]
        context = dict(request.context or {}, active_test=True)

        def set_active(ids, active):
            if ids:
                view.write(cr, uid, self.get_view_ids(ids), {'active': active}, context=context)

        set_active(disable, False)
        set_active(enable, True)

        if get_bundle:
            bundle = AssetsBundle('website.assets_frontend', cr=http.request.cr, uid=http.request.uid, context={}, registry=http.request.registry)
            return bundle.to_html()

        return True
開發者ID:JoeGazsik,項目名稱:odoo,代碼行數:19,代碼來源:main.py

示例8: test_06_paginated_css_generation1

 def test_06_paginated_css_generation1(self):
     """ Checks that a bundle creates enough ir.attachment records when its `css` method is called
     for the first time while the number of css rules exceed the limit.
     """
     # note: changing the max_css_rules of a bundle does not invalidate its attachments
     # self.cssbundle_xlmid contains 3 rules
     self.bundle = AssetsBundle(self.cssbundle_xmlid, cr=self.cr, uid=self.uid, context={}, registry=self.registry, max_css_rules=1)
     self.bundle.css()
     self.assertEquals(len(self._any_ira_for_bundle('css')), 3)
     self.assertEquals(len(self.bundle.get_attachments('css')), 3)
開發者ID:AlexM-H,項目名稱:odoo,代碼行數:10,代碼來源:test_assetsbundle.py

示例9: test_09_paginated_css_access

    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,代碼行數:34,代碼來源:test_assetsbundle.py

示例10: test_10_paginated_css_date_invalidation

    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,代碼行數:25,代碼來源:test_assetsbundle.py

示例11: test_01_generation

    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)
開發者ID:AlexM-H,項目名稱:odoo,代碼行數:16,代碼來源:test_assetsbundle.py

示例12: test_11_paginated_css_content_invalidation

    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,代碼行數:44,代碼來源:test_assetsbundle.py

示例13: test_03_date_invalidation

    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)
開發者ID:AlexM-H,項目名稱:odoo,代碼行數:20,代碼來源:test_assetsbundle.py

示例14: test_10_paginated_css_date_invalidation

    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,代碼行數:21,代碼來源:test_assetsbundle.py

示例15: test_04_content_invalidation

    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, "inherit_id": bundle_id},
        )

        bundle1 = AssetsBundle(
            self.jsbundle_xmlid, cr=self.cr, uid=self.uid, context={"check_view_ids": [newid]}, registry=self.registry
        )
        bundle1.js()
        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("js")), 1)
開發者ID:Padmahas,項目名稱:odoo,代碼行數:37,代碼來源:test_assetsbundle.py


注:本文中的openerp.addons.base.ir.ir_qweb.AssetsBundle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。