我经常遇到压倒性的Viewlet问题,而且我常常找不到它为什么会起作用。
我现在正在尝试覆盖使用浏览器层但不从plone.app.layout.viewlets.common.BaseViewlet继承的collective.googleanalytics跟踪器视图。
为了达到这个目的,我创建了一个浏览器层,它继承自c.googleanalytics,并注册并验证了everthings顺利进行。
我仍然不明白为什么使用c.googleanalytics视图而不是我的。
代码在这里: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中的其他图层覆盖图层的测试。可能是个错误?
答案 0 :(得分:3)
在你的viewlets.py中,你覆盖了这个类,但是覆盖类的真实名称是“AnalyticsViewlet”
因此,当加载zcml时,它会使用... c.google.AnalyticsTrackingViewlet:D覆盖c.google.AnalyticsTrackingViewlet。
只需更改您的zcml即可使用AnalyticsViewlet并享受。
答案 1 :(得分:0)
这看起来非常hackish。为什么不单独离开上游层?
您应该通过overrides.zcml覆盖。一旦工作/没有/图层限制,您可以将其绑定到干净的图层界面。
替代策略,不要覆盖上游视图,而是通过GS隐藏它,并为您自己的视图提供不同的名称。再次,在一个干净的层。