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

Raphael Ritz r.ritz at biologie.hu-berlin.de
Tue Aug 26 10:26:24 UTC 2008


Rafael Oliveira wrote:

[..]

> IUserPreferredLanguages has a single method that returns a sequence
> containing the preferred languages chosen by the user in his browser.
> I want to replace this adapter in by an implementation that returns
> always the same language, e.g: ["en-us"]. This way when a Plone Site
> is created the initial content will be aways translated to "en-us",
> even if the user has chosen "fr" as his preferred language in his
> browser.

Depending on what exactly it is that you want to achieve here
you might be able to configure that on the PloneLanguageTool.

> 
> Question 1: what is the best way to achieve this behavior ? As I can't
> override the adapter registration, I can think of two alternatives:
> z3c.unconfigure and a monkey patch.
> 
> Question 2: where is this design wrong ?

The point here is that Plone as a framework shouldn't use
overrides at all. This is exactly to avoid problems like the
one that you are encountering now. Overrides should be the
last resort of specific applications (e.g., a specific
site's policy product).

As has been pointed out already you can use more specific
registrations. That should always take precedence. Just
make sure that your requests fall into that more specific
situation (e.g., by making them specific to your theme).

Raphael



> I mean, if I have to think
> about overriding an override, use z3c.unconfigure or a monkey patch,
> then something is wrong with this design. Or I'm missing something ...
> 
> 
> Regards,





More information about the Product-Developers mailing list