I’m often faced to overriding viewlet issues and often I don’t find why it will works or not.
I’m now trying to override the collective.googleanalytics tracker viewlet which use a browserlayer but do not inherits from plone.app.layout.viewlets.common.BaseViewlet.
To achieve this I have created a browserlayer that inherits from c.googleanalytics one, registred it and verified everthings goes well.
I still don’t understand why the c.googleanalytics viewlet is used instead of mine.
Code is here: https://github.com/toutpt/collective.linguaanalytics
I would like to be able to know where I can add PDB to debug this. or what tools can help.
Edit:
(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>)
Edit:
It seems they are no tests around the override of layer by an other layer in plone.browserlayer. May be a bug ?
haha, silly typo.
in viewlets/configure.zcml, the viewlet is “AnalyticsTrackingViewlet”, the one from collective.googleanalytics.
In your viewlets.py you overrides this class but the real name of your overriden class is “AnalyticsViewlet”
Thus when the zcml is loaded, it overrides c.google.AnalyticsTrackingViewlet with … c.google.AnalyticsTrackingViewlet :D.
Simply change your zcml to use AnalyticsViewlet and enjoy.