2

ビューレットの問題をオーバーライドすることに直面することがよくありますが、それが機能するかどうかがわからないことがよくあります。

私は現在、browserlayer を使用しているが plone.app.layout.viewlets.common.BaseViewlet から継承していない Collective.googleanalytics トラッカー ビューレットをオーバーライドしようとしています。

これを達成するために、c.googleanalytics から継承する browserlayer を作成し、登録して、すべてがうまくいくことを確認しました。

私の代わりに 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の他のレイヤーによるレイヤーのオーバーライドに関するテストではないようです。バグかもしれませんか?

4

2 に答える 2

3

ハハ、ばかげたタイプミス。viewlets / configure.zcmlでは、ビューレットは「AnalyticsTrackingViewlet」であり、collective.googleanalyticsからのものです。

viewlets.pyでこのクラスをオーバーライドしますが、オーバーライドされたクラスの実際の名前は「AnalyticsViewlet」です。

したがって、zcmlが読み込まれると、c.google.AnalyticsTrackingViewletが... c.google.AnalyticsTrackingViewlet:Dで上書きされます。

AnalyticsViewletを使用するようにzcmlを変更するだけで、お楽しみいただけます。

于 2012-04-24T09:31:34.320 に答える
0

それは非常にハックに見えます。上流層を放っておかないのはなぜですか?

overrides.zcml でオーバーライドする必要があります。レイヤーの制限が/なくても/機能したら、それをクリーンなレイヤーインターフェイスにバインドできます。

別の戦略として、上流のビューレットをオーバーライドせずに、GS を介して非表示にし、独自のビューレットに別の名前を付けます。再び、きれいなレイヤーに。

于 2012-04-23T22:13:52.960 に答える