def test_get_navigation_root(self): """Test to see if the navigation_root is returned.""" navigation_root = portal.get_navigation_root(portal.get()) self.assertTrue(INavigationRoot.providedBy(navigation_root)) from plone.api.exc import MissingParameterError with self.assertRaises(MissingParameterError): portal.get_navigation_root()
def _get_navigation_root(context): """Find the correct navigation root.""" documents = content.find(portal_type='Document', id='front-page') if len(documents) == 0: return portal.get() front_page = documents[0].getObject() return portal.get_navigation_root(front_page)
def get_path_from_widget_start(widget): effective_path = "" if not callable(widget.start): start = widget.start if (start == "parent"): obj = aq_parent(widget.context) effective_path = '/'.join(obj.getPhysicalPath()) elif (start == "navroot"): obj = portal.get_navigation_root(widget.context) effective_path = '/'.join(obj.getPhysicalPath()) elif (start == "ploneroot"): obj = portal.get() effective_path = '/'.join(obj.getPhysicalPath()) else: effective_path = widget.start else: effective_path = widget.start(widget) return effective_path
def test_get_navigation_root(self): """Test to see if the navigation_root is returned.""" navigation_root = portal.get_navigation_root(portal.get()) self.assertTrue(INavigationRoot.providedBy(navigation_root)) self.assertRaises(ValueError, portal.get_navigation_root)