我經常面臨重寫Viewlet問題,而且我經常不知道它爲什麼會起作用。如何在使用瀏覽器的Plone中調試Viewlet創建
我現在試圖覆蓋使用瀏覽器的collective.googleanalytics跟蹤器viewlet,但不從plone.app.layout.viewlets.common.BaseViewlet繼承。
爲了實現這一目標,我創建了一個從c.googleanalytics繼承的瀏覽器層,註冊它並驗證everthings進展順利。
我還是不明白爲什麼使用c.googleanalytics的viewlet代替我的。
代碼是在這裏:https://github.com/toutpt/collective.linguaanalytics
我希望能夠知道我在哪裏可以添加PDB調試此。或者什麼工具可以幫助。
編輯:
(Pdb) self.request.__provides__.__iro__
InterfaceClass plonetheme.sunburst.browser.interfaces.IThemeSpecific>,
InterfaceClass plone.app.z3cform.interfaces.IPloneFormLayer>,
InterfaceClass z3c.form.interfaces.IFormLayer>,
InterfaceClass plone.app.discussion.interfaces.IDiscussionLayer>,
InterfaceClass collective.linguaanalytics.interfaces.ILayer>,
InterfaceClass collective.googleanalytics.interfaces.browserlayer.IAnalyticsLayer>, InterfaceClass plone.theme.interfaces.IDefaultPloneLayer>,
InterfaceClass Products.CMFDefault.interfaces.ICMFDefaultSkin>,
InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>,
InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
InterfaceClass zope.publisher.interfaces.http.IHTTPRequest>,
InterfaceClass zope.publisher.interfaces.IRequest>,
InterfaceClass zope.publisher.interfaces.IPublisherRequest>,
InterfaceClass zope.publisher.interfaces.IPublicationRequest>,
InterfaceClass zope.security.interfaces.IParticipation>,
InterfaceClass zope.publisher.interfaces.IApplicationRequest>,
InterfaceClass zope.interface.common.mapping.IEnumerableMapping>,
InterfaceClass zope.interface.common.mapping.IReadMapping>,
InterfaceClass zope.interface.common.mapping.IItemMapping>,
InterfaceClass zope.publisher.interfaces.ISkinnable>,
InterfaceClass zope.annotation.interfaces.IAttributeAnnotatable>,
InterfaceClass zope.annotation.interfaces.IAnnotatable>,
InterfaceClass zope.interface.Interface>)
編輯: 看來他們都是圍繞層的覆蓋沒有測試在plone.browserlayer的其他層。可能是一個錯誤?
這很奇怪。你的代碼看起來是正確的,因爲你在你的ILayer中擴展IAnalyticsLayer。只有當您在GS配置文件中刪除「分析」瀏覽器圖層時,看起來有點腥。 – vangheem 2012-04-23 16:51:27
將pdb粘貼到任何可以獲取請求的位置,並讓我們知道請求.__提供了__.__ iro__輸出。 – 2012-04-24 02:18:43
@vangheem刪除分析圖層是一個測試。我沒有這個推。 – toutpt 2012-04-24 08:26:29