Kevin Dangoor wrote:
> Nope, no crack there. You're right... this should more properly be a set.
>
> Kevin

I think I haven't explained myself well, I think template_vars should
be remain a list (just to avoid the try/except NameError idiom for 2.3
in every module that implements widgets). The internal implementation
for finding the union of all template_vars from all bases (which uses
set) will take care of removing duplicates...

What I was trying to say is that, being this safety-net in place, maybe
a little extra redundancy when defining template_vars on a custom
widget would not hurt. Ok, maybe a little code will disambiguate my
spaninglish :)

class MyWidget(Widget):
   template = """
   <tag xmlns:py="http://purl.org/kid/ns#"; name="${name}">
       <p py:for="i in xrange(count)">I will not repeat myself!</p>
   </tag>
   """"
   template_vars = ["name", "count"]


As "name" is already listed as a template_var at Widget, there's no
real need to list it at this subclass, but, as it's template uses it,
listing it here makes clearer that the variable comes from the widget
instance and that it can be overriden via display() (without even
looking at the template).

The thing is, the more I explain it, the less sure I am about it... :/
Better let the design-gurus decide...

Alberto

Reply via email to