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


Python view.ReferenceBrowserHelperView类代码示例

本文整理汇总了Python中archetypes.referencebrowserwidget.browser.view.ReferenceBrowserHelperView的典型用法代码示例。如果您正苦于以下问题:Python ReferenceBrowserHelperView类的具体用法?Python ReferenceBrowserHelperView怎么用?Python ReferenceBrowserHelperView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_canview

 def test_canview(self):
     makeContent(self.folder, portal_type="Document", id="doc1")
     request = TestRequest()
     helper = ReferenceBrowserHelperView(self.portal, request)
     self.assertTrue(helper.canView(self.folder.doc1))
     self.logout()
     self.assertFalse(helper.canView(self.folder.doc1))
开发者ID:RedTurtle,项目名称:archetypes.referencebrowserwidget,代码行数:7,代码来源:test_product.py

示例2: test_valuefromrequest_multi

    def test_valuefromrequest_multi(self):
        """ If the request provides UIDs take these, not the references
            on the object for the edit-view of the widget.
        """
        makeContent(self.folder, portal_type="Document", id="doc1")
        makeContent(self.folder, portal_type="Document", id="doc2")
        makeContent(self.folder, portal_type="Document", id="doc3")

        context = self.folder.doc1
        request = TestRequest()
        helper = ReferenceBrowserHelperView(context, request)
        field = context.getField("relatedItems")

        # no relations
        self.assertEqual(helper.getFieldRelations(field), [])

        # relations on the object
        context.setRelatedItems(self.folder.doc3)
        self.assertEqual(helper.getFieldRelations(field), [self.folder.doc3])

        # relations from the parameter (request, session, ...)
        uid = self.folder.doc2.UID()
        self.assertEqual(helper.getFieldRelations(field, [uid]), [self.folder.doc2])

        # invalid values
        self.assertEqual(helper.getFieldRelations(field, 1), [])
开发者ID:RedTurtle,项目名称:archetypes.referencebrowserwidget,代码行数:26,代码来源:test_product.py

示例3: test_getUidFromReference_fallback_to_UID

 def test_getUidFromReference_fallback_to_UID(self):
     _marker = object()
     class DummyRef(object):
         def UID(self):
             return _marker
     helper = ReferenceBrowserHelperView(DummyObject('/plone/foo'), TestRequest())
     self.failUnless(helper.getUidFromReference(DummyRef()) is _marker)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: test_getaturl

    def test_getaturl(self):
        context = DummyObject("/plone/layer1/layer2")
        request = TestRequest()
        helper = ReferenceBrowserHelperView(context, request)
        self.assertEqual(helper.getAtURL(), "/plone/layer1/layer2")

        context = DummyObject("/plone/layer1/with space")
        helper = ReferenceBrowserHelperView(context, request)
        self.assertEqual(helper.getAtURL(), "/plone/layer1/with%20space")
开发者ID:RedTurtle,项目名称:archetypes.referencebrowserwidget,代码行数:9,代码来源:test_product.py

示例5: test_valuefromrequest_single

    def test_valuefromrequest_single(self):
        makeContent(self.folder, portal_type="RefBrowserDemo", id="ref")
        makeContent(self.folder, portal_type="Document", id="doc2")
        makeContent(self.folder, portal_type="Document", id="doc3")

        context = self.folder.ref
        request = TestRequest()
        field = context.getField("singleRef")
        helper = ReferenceBrowserHelperView(context, request)

        # no relations
        self.assertEqual(helper.getFieldRelations(field), [])

        # relations on the object
        context.setSingleRef(self.folder.doc3)
        self.assertEqual(helper.getFieldRelations(field), [self.folder.doc3])

        # relations from the parameter (request, session, ...)
        uid = self.folder.doc2.UID()
        self.assertEqual(helper.getFieldRelations(field, uid), [self.folder.doc2])
开发者ID:RedTurtle,项目名称:archetypes.referencebrowserwidget,代码行数:20,代码来源:test_product.py

示例6: test_startupdirectory

    def test_startupdirectory(self):
        makeContent(self.folder, portal_type='RefBrowserDemo', id='ref')
        context = self.folder.ref

        request = self.app.REQUEST

        field = context.getField('multiRef5')
        helper = ReferenceBrowserHelperView(context, request)

        # no query
        self.assertEqual(helper.getStartupDirectory(field),
                         'http://nohost/plone/layer1/layer2/ref')

        # string query
        field.widget.startup_directory = 'layer2'
        self.assertEqual(helper.getStartupDirectory(field),
                         'http://nohost/plone/layer1/layer2')

        # test base query is restricted on startup directory
        self.assertFalse('path' in field.widget.getBaseQuery(context, field))
        field.widget.restrict_browsing_to_startup_directory = 1
        self.assertTrue('path' in field.widget.getBaseQuery(context, field))
        self.assertEqual(field.widget.getBaseQuery(context, field)['path'],
                         '/plone/layer1/layer2')

        field.widget.startup_directory = 'layer1'
        self.assertEqual(field.widget.getBaseQuery(context, field)['path'],
                         '/plone/layer1')

        field.widget.startup_directory = '/foo/constant'
        self.assertEqual(helper.getStartupDirectory(field),
                         'http://nohost/plone/foo/constant')

        # dynamic query
        field.widget.startup_directory_method = 'dynamicDirectory'
        self.assertEqual(helper.getStartupDirectory(field),
                         'http://nohost/plone/bar/dynamic')

        # constant query
        field.widget.startup_directory_method = 'constantDirectory'
        self.assertEqual(helper.getStartupDirectory(field),
                         'http://nohost/plone/foo/constant')

        # clean up
        field.widget.startup_directory_method = ''
开发者ID:,项目名称:,代码行数:45,代码来源:

示例7: test_startupdirectory

    def test_startupdirectory(self):
        makeContent(self.folder, portal_type="RefBrowserDemo", id="ref")
        context = self.folder.ref

        request = self.app.REQUEST

        field = context.getField("multiRef5")
        helper = ReferenceBrowserHelperView(context, request)

        # no query
        self.assertEqual(helper.getStartupDirectory(field), "http://nohost/plone/layer1/layer2/ref")

        # string query
        field.widget.startup_directory = "layer2"
        self.assertEqual(helper.getStartupDirectory(field), "http://nohost/plone/layer1/layer2")

        # test base query is restricted on startup directory
        self.assertFalse("path" in field.widget.getBaseQuery(context, field))
        field.widget.restrict_browsing_to_startup_directory = 1
        self.assertTrue("path" in field.widget.getBaseQuery(context, field))
        self.assertEqual(field.widget.getBaseQuery(context, field)["path"], "/plone/layer1/layer2")

        field.widget.startup_directory = "layer1"
        self.assertEqual(field.widget.getBaseQuery(context, field)["path"], "/plone/layer1")

        field.widget.startup_directory = "/foo/constant"
        self.assertEqual(helper.getStartupDirectory(field), "http://nohost/plone/foo/constant")

        # dynamic query
        field.widget.startup_directory_method = "dynamicDirectory"
        self.assertEqual(helper.getStartupDirectory(field), "http://nohost/plone/bar/dynamic")

        # constant query
        field.widget.startup_directory_method = "constantDirectory"
        self.assertEqual(helper.getStartupDirectory(field), "http://nohost/plone/foo/constant")

        # clean up
        field.widget.startup_directory_method = ""
开发者ID:RedTurtle,项目名称:archetypes.referencebrowserwidget,代码行数:38,代码来源:test_product.py

示例8: test_portalpath

 def test_portalpath(self):
     helper = ReferenceBrowserHelperView(self.folder, self.app.REQUEST)
     self.assertEqual(helper.getPortalPath(), "/plone")
开发者ID:RedTurtle,项目名称:archetypes.referencebrowserwidget,代码行数:3,代码来源:test_product.py


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