Jeremy Cook wrote:
I can see how it should work. However I am still having trouble. My
application is initially based on the wcsite example and is intended
to be really not any more complex than that so I wanted to keep it
that way. However I have probably inherited something from wcsite
that I don't fully understand. I made a small amount of progress but
I still get the following error with ++lang++test:
2007-07-19T13:18:26 ERROR SiteError http://neshamn.no/++lang++test
Traceback (most recent call last):
line 117, in setPreferredLanguages raise
NotCompatibleAdapterError("Adapter not compatible with "
NotCompatibleAdapterError: Adapter not compatible with
zope.i18n.interfaces.IModifiableBrowserLanguages has been used.
22.214.171.124 - - [19/Jul/2007:13:18:26 +0200] "GET /++lang++test
HTTP/1.1" 500 84 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:126.96.36.199) Gecko/20070713 Firefox/188.8.131.52"
I am not sure which adapter it is referring to and I am not sure how
to find out either. Since my site will only be in Norwegian, I have a
workaround which is to hard code the locale to 'no' so that dates
and such are formatted correctly, but I would still like to
understand what is wrong here.
Ok, let's look briefly at the ++lang++ internals. When "++lang++" string
is encountered in the path the zope.traverse.namespace.lang's adapter
traverse() method will be called. The method then try to get an object
implementing IModifiableUserPreferredLanguages from the request and
set language with help of the setPreferredLanguages() method. The
default IModifiableUserPreferredLanguages implementation
zope.app.publisher.browser.ModifiableBrowserLanguages expects some
preparation work has been done for language overriding to work (see the
base class for details).
Now let's look that's wrong with your code. At wcsite.languages there is
FixedLanguage adapter which prevents ModifiableBrowserLanguages adapter
to work mainly because it's always return hardcoded language. So if you
want to use ++lang++ namespace you need to modify your overrides.zcml to
remove FixedLanguage registration.
Dmitry Vasiliev <dima at hlabs.spb.ru>
Zope3-users mailing list