[Petal] Re: Looking for Petal info

William McKee william@knowmad.com
Tue, 30 Jul 2002 08:49:22 -0400


On 29 Jul 2002 at 12:01, Jean-Michel Hiver wrote:
> > notation:
> > 
> >   <tal:bday condition="user/is_birthday">
> >     Happy Birthday, <tal:name replace="user/real_name"/>!
> >   </tal:bday>
> >   <tal:nbday condition="not:user/is_birthday">
> >     What?! It's not your birthday?
> >     Maybe tomorrow...
> >   </tal:nbday>
> I see.... interesting. The reason for which I chose XML PI is because it
> was supported straight away by HTML tidy...

You are starting to talk in XML above my current level of understanding however, 
from a user's point of view, the <tal:name replace="user/real_name" /> syntax looks 
very clear. I like that better than the <?petal:var name=":encode user.real_name"?> 
format (partly b/c I can easily forget to add that trailing ? and although Petal now 
catches that error, it's still annoying).
 


> > How would you spell the Petal equivalent of '<a tal:attributes="href
> > string:$base/$path">'?  Does interpolation work in attributes?
> But I now see the point in ':string', I think it's interesting, I thing
> I'll write a modifier :string. And while I'm at it, I might change the
> modifier from :modifier to modifier: if it's more TAL compliant.

This will be a good thing. 
 
> > Do you expect inserted text in Petal to be predominantly structural (i.e.
> > containing un-encoded markup) or textual (encoded)?  We chose encoding as
> > the default, requiring the user to explicitly choose not to encode,
> > because we found structural insertions to be rare.  More importantly,
> > forgetting to use the 'structure' keyword tends to produce blatantly,
> > glaringly wrong results right away, whereas forgetting in the other
> > direction produces a subtle bug that is often not noticed until it is
> > accidentally triggered (or exploited!) much later.
>
> Interesting point indeed! I might change it to be the default then...

I think also that this would be a good thing to do.
 
 
> > The reason for TAL's 'repeat' namespace is twofold: it allows you to
> > avoid peculiar 'magical' names such as '__count__', and it allows you
> > full access to loop metadata in nested loops.  Consider:
> > 
> > <tr tal:repeat="row rows">
> >   <td tal:repeat="col cols">
> > Row <tal:x replace="repeat/row/index" />,
> > Column <tal:x replace="repeat/col/index" />
> >   </td>
> > </tr>
> 
> Well, here I'm not really convinced. You still have a special variable
> 'repeat'. And repeat/row/index is longer than __count__. In Perl culture,
> 'magical' variables are not necessarily a Bad Thing :-)

Nor am I really convinced but if this is the TAL spec and we want Petal to be 
compliant, it should be at least be supported. It seems to me that both ways of doing 
it are "magical" in the sense that the system is keeping track of the value for you. 
The Perl culture is familiar with magical variables whereas the Python culture 
appears to prefer a more strict OO approach.


Cheers!
William

-- 
 Lead Developer
 Knowmad Services Inc. || Internet Applications & Database Integration
 http://www.knowmad.com