How is the plone-overview.pt template rendered in the Zope2 application root (in Plone)?

StackOverflow https://stackoverflow.com/questions/16781786

  •  30-05-2022
  •  | 
  •  

Question

Plone has a nice hack that does away with the boring Zope Quickstart page that ships with Zope2. It changes this:

enter image description here

Into this:

enter image description here

Relevant code is located in Products/CMFPlone/browser/admin.zcml (https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/browser/admin.zcml#L35):

  <browser:page
      for="OFS.interfaces.IApplication"
      name="plone-overview"
      class=".admin.Overview"
      permission="zope.Public"
      template="templates/plone-overview.pt"
      />

And that explains why http://localhost:8080/plone-overview renders the plone-overview template, but why/how does the application root i.e. http://localhost:8080 render the same template?

Was it helpful?

Solution

That same ZCML file registers a AppTraverser adapter; this adapter adapts the OFS.interfaces.IApplication object to IRequest to intercept traversal.

In the IRequest adapter publishTraverse() method, when the index_html name is traversed over, the adapter returns the same plone-overview view:

def publishTraverse(self, request, name):
    if name == 'index_html':
        view = queryMultiAdapter((self.context, request),
                    Interface, 'plone-overview')
        if view is not None:
            return view
    return DefaultPublishTraverse.publishTraverse(self, request, name)

See the AppTraverser class definition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top