本文整理汇总了Python中Products.CMFPlone.browser.ploneview.Plone.getCurrentFolder方法的典型用法代码示例。如果您正苦于以下问题:Python Plone.getCurrentFolder方法的具体用法?Python Plone.getCurrentFolder怎么用?Python Plone.getCurrentFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.CMFPlone.browser.ploneview.Plone
的用法示例。
在下文中一共展示了Plone.getCurrentFolder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGetCurrentFolder
# 需要导入模块: from Products.CMFPlone.browser.ploneview import Plone [as 别名]
# 或者: from Products.CMFPlone.browser.ploneview.Plone import getCurrentFolder [as 别名]
def testGetCurrentFolder(self):
# If context is a folder, then the folder is returned
view = Plone(self.folder, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
# If context is not a folder, then the parent is returned
# A bit crude ... we need to make sure our memos don't stick in the
# tests
self._invalidateRequestMemoizations()
view = Plone(self.folder.test, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
# The real container is returned regardless of context
self._invalidateRequestMemoizations()
view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
# A non-structural folder does not count as a folder`
f = dummy.NonStructuralFolder('ns_folder')
self.folder._setObject('ns_folder', f)
self._invalidateRequestMemoizations()
view = Plone(self.folder.ns_folder, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
# And even a structural folder that is used as a default page
# returns its parent
self.folder.setDefaultPage('ns_folder')
self._invalidateRequestMemoizations()
view = Plone(self.folder.ns_folder, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
示例2: testGetCurrentFolder
# 需要导入模块: from Products.CMFPlone.browser.ploneview import Plone [as 别名]
# 或者: from Products.CMFPlone.browser.ploneview.Plone import getCurrentFolder [as 别名]
def testGetCurrentFolder(self):
# If context is a folder, then the folder is returned
view = Plone(self.folder, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
# If context is not a folder, then the parent is returned
# A bit crude ... we need to make sure our memos don't stick in the tests
del self.app.REQUEST.__annotations__
view = Plone(self.folder.test, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
# The real container is returned regardless of context
del self.app.REQUEST.__annotations__
view = Plone(self.folder.test.__of__(self.portal), self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
# A non-structural folder does not count as a folder`
f = dummy.NonStructuralFolder('ns_folder')
self.folder._setObject('ns_folder', f)
del self.app.REQUEST.__annotations__
view = Plone(self.folder.ns_folder, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)
# And even a structural folder that is used as a default page
# returns its parent
self.setRoles(['Manager'])
self.folder.invokeFactory('Topic', 'topic')
del self.app.REQUEST.__annotations__
view = Plone(self.folder.topic, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder.topic)
self.folder.saveDefaultPage('topic')
del self.app.REQUEST.__annotations__
view = Plone(self.folder.topic, self.app.REQUEST)
self.assertEqual(view.getCurrentFolder(), self.folder)