[Zope] Getting aquisition values from object attribute

Max M maxm@mxm.dk
Mon, 24 Mar 2003 16:01:54 +0100


Toby Dickenson wrote:

>import Acquisition
>
>class MyAttr(Acqusition.Implicit):
>  
>

Ok ... I have changed my class to the code below (only relevant code shown):

But it gives me a recursion error. I have no ide as to why:

regards Max M

    from Acquisition import Implicit
   
    class I18nBase(Implicit):

        textBundle = {}
   
        __allow_access_to_unprotected_subobjects__=1
   
        def __getitem__(self, textId):
            """
            Takes a short text id and returns a string
            in the selected language
            """
            default_language = 'dk'
            error_msg = '<font color="red"><b>TRANSLATION 
MISSING</b></font>'
            language = getattr(self, 'language', default_language)
            return self.textBundle.get(
                    language, default_language).get(textId, error_msg)
   
   
    class Test_i18n(I18nBase):   
        "i18n for the test page"
        t = {}
        t['dk'] = {}
        t['uk'] = {}
   
        t['dk']['hello'] = 'Hej verden'
        t['uk']['hello'] = 'Hello World'
   
   
    ######################
    class ots_Department(TheUsualZopeClasses):
            "A normal working Zope product"
            test = PageTemplateFile('zpt/test', globals())
            test_i18n = Test_i18n()
   
    ######################
    ## test.zpt
    <span tal:define="i18n here/test_i18n">
        <span tal:replace="i18n/hello">Hej verden</span>
    </span>