[Product-Developers] How to override an adapter which is already overridden by CMFPlone ?

Wichert Akkerman wichert at wiggy.net
Mon Aug 25 18:14:48 UTC 2008


Previously Rafael Oliveira wrote:
> Hi,
> 
> I have the following problem: I want to provide a custom
> implementation for the following adapter:
> 
>     <adapter
>         for="zope.publisher.interfaces.http.IHTTPRequest"
>         provides="zope.i18n.interfaces.IUserPreferredLanguages"
>         factory="Products.Five.i18n.PTSLanguages"
>         />
> 
> This ZCML snippet can be found in Products/CMFPlone/overrides.zcml. I
> believe it overrides the original adapter registered in
> `Products/Five/i18n.zcml`.
> 
> I created a package called `my.package`, added a `browser.py` file
> with the adapter class and an `overrides.zcml` containing the adapter
> registration. Then I added a ZCML slug to my `etc/package-includes`
> called `my.package-overrides.zcml`, containing the line:
> 
> <include package="my.package" file="overrides.zcml" />
> 
> When I start my Zope instance I get the following error:
> 
> zope.configuration.config.ConfigurationConflictError: Conflicting
> configuration actions
>   For: ('adapter', (<InterfaceClass
> zope.publisher.interfaces.http.IHTTPRequest>,), <InterfaceClass
> zope.i18n.interfaces.IUserPreferredLanguages>, '')
>     File "/home/rafaelb/[snipped]/lib/python/my/package/overrides.zcml",
> line 3.2-7.4
>         <adapter
>             for="zope.publisher.interfaces.http.IHTTPRequest"
>             provides="zope.i18n.interfaces.IUserPreferredLanguages"
>             factory="my.package.ModifiedPreferredLanguages"
>         />
>     File "/home/rafaelb/[snipped]/buildout/parts/plone/CMFPlone/overrides.zcml",
> line 6.4-10.10
>           <adapter
>               for="zope.publisher.interfaces.http.IHTTPRequest"
>               provides="zope.i18n.interfaces.IUserPreferredLanguages"
>               factory="Products.Five.i18n.PTSLanguages"
>               />
> 
> What am I doing wrong ?

You can't override an override. Your only hope may be z3c.unconfigure:
http://pypi.python.org/pypi/z3c.unconfigure

Wichert.

-- 
Wichert Akkerman <wichert at wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.




More information about the Product-Developers mailing list