[Zope] NamedTemplate.__call__ not returning anything
Dieter Maurer
dieter at handshake.de
Mon Jan 14 13:57:57 EST 2008
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/namedtemplate.py (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__(....)".
--
Dieter
More information about the Zope
mailing list