plone - 如何使用 browserlayer 在 Plone 中调试 viewlet 创建

标签 plone

我经常面临覆盖 View 问题,而且常常不明白为什么它会起作用或不起作用。

我现在正在尝试覆盖使用浏览器层但不继承自 plone.app.layout.viewlets.common.BaseViewlet 的 Collective.googleanalytics 跟踪器 View 。

为了实现这一目标,我创建了一个继承自 c.googleanalytics 的浏览器层,对其进行注册并验证一切顺利。

我仍然不明白为什么使用 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 中的其他层覆盖层进行测试。可能是一个错误?

最佳答案

哈哈,愚蠢的错别字。 在 viewlets/configure.zcml 中,Viewlet 是“AnalyticsTrackingViewlet”,来自 Collective.googleanalytics 的 Viewlet。

在 viewlets.py 中,您重写了此类,但重写的类的真实名称是“AnalyticsViewlet”

因此,当加载 zcml 时,它会使用 ... c.google.AnalyticsTrackingViewlet 覆盖 c.google.AnalyticsTrackingViewlet :D。

只需更改您的 zcml 即可使用 AnalyticsViewlet 并享受。

关于plone - 如何使用 browserlayer 在 Plone 中调试 viewlet 创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10278350/

相关文章:

plone - zc.recipe.cmmi 中的错误?

python - 我可以单独获得 Plone 内容的删除权限吗?

plone - 如何在我的 Plone 4.3.9 站点中启用旧样式集合?

plone - 如何在启动时初始加载 Plone 站点时订阅

python - 如果特定文件夹不存在,请调整 Plone 的宏以不显示任何内容?

jakarta-ee - 使用 Java 和 Plone CMS 进行内容交付

python - pmr2-oauth(plone 中的一个包)的内容类型范围管理器包含哪些内容

Plon 链接类型 - 打开外部站点

plone - 如何使用 Diazo 主题取消所有 tinymce 窗口的主题

plone - 处理Plone中的 View 隐式获取问题