我经常面临重写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