def getRelativePaths(self): prefix = '/' + self.context.virtual_url_path() paths = [prefix + '/', prefix + '/view'] defaultView = getObjectDefaultView(self.context) if defaultView: path = prefix + '/' + defaultView if path not in paths: # it could be paths.append(path) parent = aq_parent(self.context) if parent is not None: parentDefaultView = getObjectDefaultView(parent) if parentDefaultView == self.context.getId(): parentPrefix = '/' + parent.virtual_url_path() paths.append(parentPrefix) if parentPrefix == '/': # special handling for site root since parentPrefix # does not make sense in that case. # Additionally, empty site roots were not getting # purge paths /VirtualHostBase/http/site.com:80/site1/VirtualHostRoot/_vh_site1/ # was getting generated but not # /VirtualHostBase/http/site.com:80/site1/VirtualHostRoot/_vh_site1 # which would translate to http://site.come/ getting invalidated # but not http://site.come paths.append('') paths.append('/view') else: paths.append(parentPrefix + '/') paths.append(parentPrefix + '/view') return paths
def getRelativePaths(self): prefix = '/' + self.context.virtual_url_path() paths = [prefix + '/', prefix + '/view'] defaultView = getObjectDefaultView(self.context) if defaultView: path = prefix + '/' + defaultView if path not in paths: # it could be paths.append(path) parent = aq_parent(self.context) if parent is None: return paths parentDefaultView = getObjectDefaultView(parent) if parentDefaultView == self.context.getId(): parentPrefix = '/' + parent.virtual_url_path() paths.append(parentPrefix) if parentPrefix == '/': # special handling for site root since parentPrefix # does not make sense in that case. # Additionally, empty site roots were not getting # purge paths # /VirtualHostBase/http/site.com:80/site1/VirtualHostRoot/_vh_site1/ # was getting generated but not # /VirtualHostBase/http/site.com:80/site1/VirtualHostRoot/_vh_site1 # which would translate to http://site.come/ getting # invalidated but not http://site.come paths.append('') paths.append('/view') else: paths.append(parentPrefix + '/') paths.append(parentPrefix + '/view') return paths
def __call__(self): # 1. Attempt to look up a ruleset using the default lookup ruleset = lookup(self.published) if ruleset is not None: return ruleset registry = queryUtility(IRegistry) if registry is None: return None ploneCacheSettings = registry.forInterface( IPloneCacheSettings, check=False) # 2. Get the name of the published object name = getattr(self.published, '__name__', None) if name is None: return None # 3. Look up the published name in the page template mapping if ploneCacheSettings.templateRulesetMapping is not None: ruleset = ploneCacheSettings.templateRulesetMapping.get(name, None) if ruleset is not None: return ruleset # 4. Find the parent of the published object parent = getattr(self.published, '__parent__', None) if parent is None: return None # 4.1. If the parent is a content object: parentPortalType = getattr(aq_base(parent), 'portal_type', None) if parentPortalType is None: return None # 4.1.1. Get the default view of the parent content object defaultView = getObjectDefaultView(parent) # 4.1.2. If the name of the published object is the same as the # default view of the parent: if defaultView != name: return None # 4.1.2.1. Look up the parent type in the content type # mapping if ploneCacheSettings.contentTypeRulesetMapping is not None: ruleset = ploneCacheSettings.contentTypeRulesetMapping.get( parentPortalType, None ) if ruleset is not None: return ruleset # 4.1.2.2. Look up a ruleset on the parent object and # return ruleset = lookup(parent) if ruleset is not None: return ruleset
def __call__(self): # 1. Attempt to look up a ruleset using the default lookup ruleset = lookup(self.published) if ruleset is not None: return ruleset registry = queryUtility(IRegistry) if registry is None: return None ploneCacheSettings = registry.forInterface( IPloneCacheSettings, check=False) # 2. Get the name of the published object name = getattr(self.published, '__name__', None) if name is None: return None # 3. Look up the published name in the page template mapping if ploneCacheSettings.templateRulesetMapping is not None: ruleset = ploneCacheSettings.templateRulesetMapping.get(name, None) if ruleset is not None: return ruleset # 4. Find the parent of the published object parent = getattr(self.published, '__parent__', None) if parent is None: return None # 4.1. If the parent is a content object: parentPortalType = getattr(aq_base(parent), 'portal_type', None) if parentPortalType is None: return None # 4.1.1. Get the default view of the parent content object defaultView = getObjectDefaultView(parent) # 4.1.2. If the name of the published object is the same as the # default view of the parent: if defaultView != name: return None # 4.1.2.1. Look up the parent type in the content type # mapping if ploneCacheSettings.contentTypeRulesetMapping is not None: ruleset = ploneCacheSettings.contentTypeRulesetMapping.get( parentPortalType, None, ) if ruleset is not None: return ruleset # 4.1.2.2. Look up a ruleset on the parent object and # return ruleset = lookup(parent) if ruleset is not None: return ruleset
def getRelativePaths(self): prefix = self.context.absolute_url_path() yield prefix + '/' yield prefix + '/view' defaultView = getObjectDefaultView(self.context) if defaultView: yield prefix + '/' + defaultView parent = aq_parent(self.context) if parent is not None: parentDefaultView = getObjectDefaultView(parent) if parentDefaultView == self.context.getId(): parentPrefix = parent.absolute_url_path() yield parentPrefix yield parentPrefix + '/' yield parentPrefix + '/view'
def getRelativePaths(self): prefix = '/' + self.context.virtual_url_path() paths = [prefix + '/', prefix + '/view'] defaultView = getObjectDefaultView(self.context) if defaultView: path = prefix + '/' + defaultView if path not in paths: # it could be paths.append(path) parent = aq_parent(self.context) if parent is not None: parentDefaultView = getObjectDefaultView(parent) if parentDefaultView == self.context.getId(): parentPrefix = '/' + parent.virtual_url_path() paths.append(parentPrefix) paths.append(parentPrefix + '/') paths.append(parentPrefix + '/view') return paths
def test_not_IBrowserDefault_actiononly(self): context = DummyNotBrowserDefault('testtype', 'string:${object_url}/defaultView') self.assertEqual('defaultView', getObjectDefaultView(context))
def test_browserdefault(self): context = DummyContent() self.assertEqual('defaultView', getObjectDefaultView(context))
def test_not_content(self): context = DummyNotContent() self.assertEqual(None, getObjectDefaultView(context))
def test_not_IBrowserDefault_actiononly(self): context = DummyNotBrowserDefault("testtype", "string:${object_url}/defaultView") self.assertEquals("defaultView", getObjectDefaultView(context))