2013-05-27 21 views
3

Plone有一個很好的破解,消除無聊Zope快速入門頁面與Zope2一起發貨。它改變了這一點:plone-overview.pt模板是如何在Zope2應用程序根目錄(在Plone中)呈現的?

enter image description here

進入這個:

enter image description here

相關的代碼位於Products/CMFPlone/browser/admin.zcmlhttps://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" 
     /> 

這解釋了爲什麼http://localhost:8080/plone-overview呈現的Plone - 概述模板,但爲什麼/如何應用程序根即http://localhost:8080呈現相同的模板?

回答

5

相同的ZCML文件註冊AppTraverser adapter;此適配器將OFS.interfaces.IApplication對象調整爲IRequest以攔截遍歷。

IRequest適配器publishTraverse()方法中,當index_html名稱被遍歷過,適配器返回相同plone-overview視圖:

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) 

AppTraverser class definition

+0

頭腦風暴......謝謝! – aclark

+0

神祕終於透露出來,Dank je wel! +1 –

相關問題