[Petal] TPJ article 0.1
Jean-Michel Hiver
jhiver at mkdoc.com
Mon Aug 25 12:51:11 BST 2003
Hi,
> Yes, I have read it. I think your examples are good and like that you
> give a behind-the-scenes look at how Petal operates (in fact, I'd rename
> Advanced Petal to something like Inside Petal or The Code Behind Petal;
> I think of advanced petal as more ways to use it, not how it works; the
> modifiers section would be appropriate as an Advanced Petal topic).
Ok, renamed it to "Inside Petal"
> I tried to put myself into the frame of mind of someone just coming
> across the article. As such, I think you save some of the most
> interesting info for the last (such as caching, modular architecture,
> and the other bells and whistles mentioned in the conclusion) and don't
> harp on the benefits of the TAL specs enough (you say it's a good idea
> but don't really sell the reader on why a Perl programmer should be
> implementing a spec from a Python project).
OK. I have rephrased the introduction to emphasize on the benefits of
TAL. However I am not doing a full "sales job" on the benefits of TAL as
you mentioned. Probably because:
a/ It would destroy the structure of the article.
b/ It is an article about Petal, not TAL, although they are naturally
very similar.
c/ I'll reference "At the Forge" article so that people can read about
those benefits.
> I'm a bit confused about the canonicalizer section. I get the input
> parser stuff but you say that there are two output canonicalizers. Your
> example shows what a canonicalizer does with the input. However, the
> output you show does not look like XHTML. If I understand correctly, the
> canonicalizer builds the Perl sub that eventually generates the
> page. Depending on the output canonicalizer chosen, the code gets built
> and the data gets handled a bit differently. Is that accurate? Or does
> the canonicalizer sit before the CodeGenerator?
Yes, the canonicalizer sits before the code generator.
> write Petal syntax but never really explain why. In fact, I've never
> really understood this. Perhaps you can clarify your reasoning in the
> article?
I have reworded this section as follows:
-------------------------------- %< --------------------------------
At this point I have to confess: Petal started as just a big hack. It is
builton top of a previous twist in which I used a syntax made of XML
processing instructions as follows:
<?if name="something"?>
... do something <?var name="foo"?> etc...
<?end?>
Looks familiar huh?
Instead of building a module which directly converts XML events intoPerl
code, I've built a module which converts XML events into the syntax
above since the system above was already working (!).
I've also made this module turn an $inline_variable into an
<?var name="inline_variable"?>.
The Petal canonicalizer was born. It turns alternate syntaxes (TAL, inline) into the original canonical syntax, which unfortunately happens to look very ugly.
A neat effect is that you can use all three syntaxes at the same time,
so this is legal:
<?if name="true:something"?>
<p tal:repeat="item something">$item</p>
<?end?>
However you should really stick with the standard TAL syntax as much as
possible:
<p tal:condition="true:something"
tal:repeat="item something"
tal:content="item">Exempli Gratia</p>
If you want more information on the canonical syntax, see perldoc Petal
-------------------------------- %< --------------------------------
> A question about modifiers. Would it be possible to create a modifier
> library instead of a bunch of independent modules? According to the
> article, the existing syntax names the modifier based on the filename.
> What would need to change to allow Petal to install multiple modifiers
> from a single module?
It is possible indeed. You could have:
Petal::Hash::MultipleStuff::One
Petal::Hash::MultipleStuff::Two
And then have:
package Petal::Hash::MultipleStuff
use Petal::Hash;
use strict;
$Petal::Hash::MODIFIERS->{'one:'} = 'Petal::Hash::MultipleStuff::One';
$Petal::Hash::MODIFIERS->{'two:'} = 'Petal::Hash::MultipleStuff::Two';
1;
__END__
Then Petal would install multiplestuff:, which in turn would install
one: and two:.
> Other minor issues:
> - Digital Creations is now (according to Reuven's article) the Zope
> Corporation
Fixed.
> - client should be plural in 1st sentence of Hello World example
Fixed.
> - It should be I in last sentence of 1st para. of same ex?
Fixed.
> - I've noticed in the Petal docs that you are starting to use the tal
> namespace. Why do you revert to the petal namespace in the article?
> That may be confusing to users who want to install and use Petal.
Fixed.
> - In Adv Petal section, you refer to Fergal's Daly; although I suppose
> that Fergal possesses his last name, I'm guessing you meant to put
> that possessive after Daly.
Fixed.
> My $0.02,
They were worth more than that :)
Cheers,
More information about the Petal
mailing list