On 10/25/05, Jeff Grimmett <[EMAIL PROTECTED]> wrote:
> Here is the exception I am looking at right now:
> File "D:\GL\grimmlabs\grimmlabs\templates\master.py", line
> 17
> SyntaxError: 'yield' outside function (master.py, line 17)
Can you send a copy of your master.kid? Since you say that this error
keeps coming up, I'm beginning to think that something is amiss in the
template.
> One other thing that bothers me: the interface to Kid seems to be awefully
> brittle. For example, take the default project used in the 'getting
> started' examples. The initial project's 'Root' controller returns a dict
> that contains the 'now' element that is then plopped into the default
> template. HOWEVER, if that returned value is changed to an empty dict
> without first eliminating it from the template, an exception will be raised.
> My expectation here would be that excess values would be ignored. Is this a
> Kid thing? Here's the basis of my expectation:
>
> >>> d = {'test1':'test1', 'test2':'test3'}
> >>> d
> {'test1': 'test1', 'test2': 'test3'}
> >>> s = "%(test1)s %(test2)s"
> >>> s%d
> 'test1 test3'
> >>> s2 = "%(test1)s"
> >>> s2%d
> 'test1'
>
> As can be seen in the example, s2 only 'knows' to 'render' the 'test1'
> member, and even though it is passed a dict with both 'test1' and 'test2',
> Python doesn't complain about the extra data.
Actually, the code above is not equivalent to what you described with
the Kid template. This code is equivalent:
>>> d = {'test1':'test1', 'test2':'test3'}
>>> s = "%(test1)s %(test2)s"
>>> s%d
'test1 test3'
>>> del d["test1"]
>>> s%d
Traceback (most recent call last):
File "<stdin>", line 1, in ?
KeyError: 'test1'
Currently, with Kid, you can do this:
${getattr(self, 'now', None)}
if you want to be certain to not blow up on a missing variable.
There's a ticket open to add a trivial function to Kid that does the
same thing in a prettier way.
> I don't know if you would classify it as a bug or a design limitation that
> can't be avoided, or something else entirely.
something else entirely :)
> I'm pretty jazzed about what I *should* be able to do with TG once I get up
> to speed on all the components, but this initial speed bump is really
> harshing my buzz. Be happy to supply files or whatever else is needed to
> help me understand what is happening.
The learning curve's not bad, but there is some learning to do and the
docs do not touch upon every last possibility... Bit by bit, it gets
better, though. And there are lots of people answering questions here
now!
Kevin