Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    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
Esempio n. 4
0
    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
Esempio n. 5
0
 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'
Esempio n. 6
0
    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'
Esempio n. 7
0
    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
Esempio n. 8
0
    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
Esempio n. 9
0
 def test_not_IBrowserDefault_actiononly(self):
     context = DummyNotBrowserDefault('testtype',
                                      'string:${object_url}/defaultView')
     self.assertEqual('defaultView', getObjectDefaultView(context))
Esempio n. 10
0
 def test_browserdefault(self):
     context = DummyContent()
     self.assertEqual('defaultView', getObjectDefaultView(context))
Esempio n. 11
0
 def test_not_content(self):
     context = DummyNotContent()
     self.assertEqual(None, getObjectDefaultView(context))
Esempio n. 12
0
 def test_not_IBrowserDefault_actiononly(self):
     context = DummyNotBrowserDefault('testtype', 'string:${object_url}/defaultView')
     self.assertEqual('defaultView', getObjectDefaultView(context))
Esempio n. 13
0
 def test_browserdefault(self):
     context = DummyContent()
     self.assertEqual('defaultView', getObjectDefaultView(context))
Esempio n. 14
0
 def test_not_content(self):
     context = DummyNotContent()
     self.assertEqual(None, getObjectDefaultView(context))
Esempio n. 15
0
 def test_not_IBrowserDefault_actiononly(self):
     context = DummyNotBrowserDefault("testtype", "string:${object_url}/defaultView")
     self.assertEquals("defaultView", getObjectDefaultView(context))