本文整理汇总了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))
示例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), [])
示例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)
示例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")
示例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])
示例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 = ''
示例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 = ""
示例8: test_portalpath
def test_portalpath(self):
helper = ReferenceBrowserHelperView(self.folder, self.app.REQUEST)
self.assertEqual(helper.getPortalPath(), "/plone")