def test_disable(self): from collective.lineage.interfaces import IChildSite utils.enable_childsite(self.childsite) self.assertTrue(IChildSite.providedBy(self.childsite)) utils.disable_childsite(self.childsite) self.assertFalse(IChildSite.providedBy(self.childsite))
def enableChildSite(event): """When a lineage folder is created, turn it into a component site """ if not IChildSite.providedBy(event.object): return folder = event.object enableFolder(folder)
def getNextChildSite(context, portal): """Returns the nearest parent object implementing IChildSite. Code borrowed from plone.app.layout.navigation.root.getNavigationRootObject """ obj = context while not IChildSite.providedBy(obj) and\ aq_base(obj) is not aq_base(portal): obj = utils.parent(obj) return obj
def _find_site(ctx): # First, stop at IPloneSiteRoot if IPloneSiteRoot.providedBy(ctx): return ctx # Then walk up ctx = aq_parent(ctx) if IChildSite.providedBy(ctx): return ctx return _find_site(ctx)
def absolute_url(self, relative=0): if not IChildSite.providedBy(self): return self._absolute_url(relative) elif relative: self.virtual_url_path() url = map_url('/'.join(self.getPhysicalPath()), aq_acquire(self, 'REQUEST')) return url
def getNextChildSite(context, portal): """Returns the nearest parent object implementing IChildSite. Code borrowed from plone.app.layout.navigation.root.getNavigationRootObject """ obj = context while not IChildSite.providedBy(obj) and aq_base(obj) is not aq_base(portal): obj = utils.parent(obj) if obj is None: return return obj
def isChildSite(self): """Return ``True``, if the current context is within a childsite. """ context = self.context request = self.request portal_state = getMultiAdapter( (context, request), name="plone_portal_state" ) root_path = portal_state.navigation_root_path() nav_root = self.context.restrictedTraverse(root_path) return IChildSite.providedBy(nav_root)
def current_childsite(self): """Return the current childsite. """ childsite = None context = self.context request = self.request portal_state = getMultiAdapter( (context, request), name="plone_portal_state" ) root_path = portal_state.navigation_root_path() nav_root = self.context.restrictedTraverse(root_path) if IChildSite.providedBy(nav_root): childsite = nav_root return childsite
def getFields(self): if IChildSite.providedBy(self.context): return self.fields return []
def __call__(self): return IChildSite.providedBy(self.context)
def isChildSite(self): portal_state = self.context.restrictedTraverse("plone_portal_state") root_path = portal_state.navigation_root_path() nav_root = self.context.restrictedTraverse(root_path) return IChildSite.providedBy(nav_root)
def isChildSite(self): portal_state = self.context.restrictedTraverse('plone_portal_state') root_path = portal_state.navigation_root_path() nav_root = self.context.restrictedTraverse(root_path) return IChildSite.providedBy(nav_root)
def enabled(self): """True, if context is a lineage subsite. """ return IChildSite.providedBy(self.context)