[Grok-dev] Re: Organizing the further development effort

Philipp von Weitershausen philipp at weitershausen.de
Thu May 24 19:25:55 EDT 2007

Malthe Borch wrote:
> Implementing a simple language-handler much like Philip's example 11.3.1 
> (World Cookery), I thought about how one would do this in a grokkish way 
> and where this could be documented and/or shared.

It's just a simple adapter. While in regular Zope 3 you register it via 
the <adapter /> ZCML directive, you simply inherit from grok.Adapter in 
Grok. That's about it.


   import grok
   from zope.publisher.browser import BrowserLanguages

   class BrowserFormLanguages(BrowserLanguages, grok.Adapter):

       def getPreferredLanguages(self):
         langs = super(BrowserFormLanguages,
         form_lang = self.request.get("ZopeLanguage", None)
         if form_lang is not None:
             langs.insert(0, form_lang)
         return langs

http://worldcookery.com -- Professional Zope documentation and training

More information about the Grok-dev mailing list