[much snippage]

Try adding the code snippet shown below.  It detects
whether a principal is available and only checks
for preferences if there is one.  
class BrowserFormLanguages(BrowserLanguages):
    language_store = []  # ignore this for now
    def __init__(self, request):
        super(BrowserFormLanguages, self).__init__(request)
        print "created BFL", self.language_store
    def setPreferredLanguages(self, langs):
        #prefs = UserPreferences()
        #print prefs.eods.general.language
        self.language_store = langs
        print "set language", self.language_store
    def getPreferredLanguages(self):
        langs =
        if self.language_store:
            langs = self.language_store + langs
        form_lang = self.request.get("Language", None)
        if form_lang is not None:
            langs.insert(0, form_lang)

        # LOOK HERE 
        # don't look up preferences unless we have
        # something which _has_ preferences!
        if self.request.principal != None:
            prefs = UserPreferences()
            print "Prefs", repr(prefs)
            # substitute your own 'None' value case.
            if prefs.eods.general.language is not None:  
                langs.insert(0, prefs.eods.general.language)

        print "My prefered override", langs
        return langs

The principal annotation error seems to be avoided (since
we've made sure we have a principal).  

The language does seem to be set to the preference for page
displays, so what Philipp said about being able to ignore
uninteresting things until we've traversed far enough
was a good hint.

Zope3-users mailing list

Reply via email to