Dieter Maurer, on 2008-01-14:
> Maurits van Rees wrote at 2008-1-13 23:32 +0000:
>>I have some code where I try to get a named template and render it and
>>if it fails I render a default template instead.  But this fails,
>>presumably because the __call__ method of NamedTemplate does not
>>return anything.  From zope/formlib/ (Zope 2.10):
>>class NamedTemplate(object):
>>    def __init__(self, name):
>>        self.__name__ = name
>>    def __get__(self, instance, type=None):
>>        if instance is None:
>>            return self
>>        return component.getAdapter(instance, INamedTemplate, self.__name__)
>>    def __call__(self, instance, *args, **kw):
>>        self.__get__(instance)(*args, **kw)
>>I seems strange to me that __call__ does not actually return
>>anything.  Is it just me?
> It returns only if you use "return" (otherwise, it returns "None").
> Thus, try "return self.__get__(....)".

I know. :) I think you misunderstood me there.  This class is from
core Zope (zope.formlib.namedtemplate).  So to refrase my question:
why does this call method not do "return self.__get(....)"?  Looks
like a bug to me, but this line has been there since 2005 and named
templates do seem to work fine, so I am confused.

Maurits van Rees |
            Work |
"This is your day, don't let them take it away." [Barlow Girl]

Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to