Jean-Michel Hiver | 4 Jun 15:48

[Release] Petal 2.06

Hi List,

Here is a release with a few bug-fixes and minor improvements:

- An HTML-friendly error mode:

If you set $Petal::HTML_ERRORS = 1, Petal will display the errors in the 
HTML rather than die(). It is mainly useful if you intend to give remote 
access to the templates of your application to people who do not have 
access to the machine or its logs.

- Entity encoding is fixed on overloaded objects. (That's the bug which 
Bruno filed)

- Metal use-macro now does not include document declarations at the top 
of included templates, as it should.

Enjoy!

Cheers,
Jean-Michel.

Yuval Kogman | 7 Jun 02:57

METAL with TAL inside

Hi,

In the effort of creating Maypole::View::Petal, I'm breaking my head
over a transliteration of the orginal template toolkit templates to
Petal.

There is extensive use of macros in the TT code, which I guess is a good
thing. I attempted to keep the templates pretty much 1:1 where possible,
but I'm now stuck.

Here is an example template:

<span metal:define-macro="display_line">
	<span tal:repeat="col classmetadata/colums" tal:omit-tag="string:1">
		<td tal:condition="false: equal:col id">
			<?if name="equal:col url"?>
				<a tal:attr="href item/url" tal:content="item/url"/>
...

It gives

	<span tal:repeat="col classmetadata/colums" tal:omit-tag="string:1">
		<td tal:condition="false: equal:col id">
			
				<a tal:attr="href item/url" tal:content="item/url"></a>
			
		</td>
	...

and so on as the output to the browser.
(Continue reading)

Jean-Michel Hiver | 7 Jun 08:29

Re: METAL with TAL inside

Yuval Kogman wrote:
> Hi,
> 
> In the effort of creating Maypole::View::Petal, I'm breaking my head
> over a transliteration of the orginal template toolkit templates to
> Petal.

Cool :-)

> There is extensive use of macros in the TT code, which I guess is a good
> thing. I attempted to keep the templates pretty much 1:1 where possible,
> but I'm now stuck.
> 
> 
> Here is an example template:
> 
> <span metal:define-macro="display_line">
> 	<span tal:repeat="col classmetadata/colums" tal:omit-tag="string:1">
> 		<td tal:condition="false: equal:col id">
> 			<?if name="equal:col url"?>
> 				<a tal:attr="href item/url" tal:content="item/url"/>
> ...

It which file do you define this macro?

> It gives
> 
> 	<span tal:repeat="col classmetadata/colums" tal:omit-tag="string:1">
> 		<td tal:condition="false: equal:col id">
> 			
(Continue reading)

Yuval Kogman | 7 Jun 14:47

Re: METAL with TAL inside

On Mon, Jun 07, 2004 at 07:29:24 +0100, Jean-Michel Hiver wrote:

> If you don't declare the Petal namespace, the prefix by default is 
> petal:, not tal:

Turns out this was it.. I assumed the tal prefix would inherit from the
main document... It's less to type, so... =P

> This will not work. Petal's implementation of METAL is only partial, and 
> you need to read the docs :)

funny, it does work... =)

The file is called "macros", and the macro is called "display_line", so
it's not all that naughty.

Now all I need is to work around using TALES that look like
"object/laadidaa/?var" and get the var to interpolate before the path
expansion. I think using ${var} syntax is very ingruiging, because in

--

-- 
 ()  Yuval Kogman <nothingmuch@...> 0xEBD27418  perl hacker &
 /\  kung foo master: /me kicks %s on the nose: neeyah!!!!!!!!!!!!!!!!!

Michele Beltrame | 9 Jun 20:17
Gravatar

More problems with UTF-8

Hi all!

I'm experiencing some more problems with charsets. I subclassed Petal's
process() to always output UTF-8:

package Petal::AlwaysUTF8;
use strict;
use base qw /Petal/;
use Encode;

sub process
{
   my $self = shift;
   my $res = $self->SUPER::process (@_);
   return Encode::encode ('utf8', $res);
}

This works just fine as all entities on the templates get correctly
( &agrave;, &nbsp;, ...) get correctly converted to UTF-8.

The problem arises with UTF-8 data which is inserted into the template at
runtime (from the script, data I get from the database). This data is
already UTF-8 and it seems it gets converted again by my subclassed
process() method, which of course leads to weird display.

I tried:

use encoding 'utf8';

The results are a mess: if I don't use my subclassed process() method
(Continue reading)

Jean-Michel Hiver | 16 Jun 16:34
Subject: Cool :-)

See attached message. How nice!
Gravatar
From: Michele Beltrame <mb@...>
Subject: Two Italian articles on Petal
Date: 2004-06-16 13:03:03 GMT
Hi Jean-Michel!

I wrote two articles about Petal for an Italian developer magazine: the
first is now out, and the second will be in in July.

Just thought you'd want to know. ;) Petal is fantastic!

	Talk to you soon, Michele.

--

-- 
Michele Beltrame
http://www.italpro.net/mb/
ICQ# 76660101 - e-mail: mb@...
Yuval Kogman | 16 Jun 17:21

Maypole

Hi,

I created a dirt simple Maypole::View::Petal, which is really nothing
special.

I'm not enjoying the template conversion, though.

Would someone please look at them, and see how to do them? My schedule
is becomming too tight to again, and I won't fit it this week. I
converted about 30% so far, and you can see some of this working at

	http://nothingmuch.woobling.org/beerdb

Important parts are missing.

I just can't eat that TT stuff - it's so ugly, and it uses stuff which
is just not right to do under Petal.

Something which might resolve the issues I'm having is to port the
	object/path/?thing
extension that Zope's implementation has, which interpolates thing into
the path, and then evaluates the path. This is used extensively under
Simon Cozens original TT templates.

I've used Petal::Utils for some of the template stuff.

Note that the reason I use Petal is that my X?HTML is very bad. It would
be a good idea for someone to look 

--

-- 
(Continue reading)

Yuval Kogman | 16 Jun 18:00

Re: Maypole

On Wed, Jun 16, 2004 at 18:21:35 +0300, Yuval Kogman wrote:

> 	http://nothingmuch.woobling.org/beerdb

To see the original working on the same db:

http://beerdb.woobling.org/beerdborig

note that the virtual host is different, because otherwise Maypole
screws up. See http://rt.cpan.org/NoAuth/Bug.html?id=6622

--

-- 
 ()  Yuval Kogman <nothingmuch@...> 0xEBD27418  perl hacker &
 /\  kung foo master: /methinks long and hard, and runs away: neeyah!!!

Jean-Michel Hiver | 16 Jun 18:01

Re: Maypole

Yuval Kogman wrote:

>Hi,
>
>I created a dirt simple Maypole::View::Petal, which is really nothing
>special.
>
>I'm not enjoying the template conversion, though.
>
>Would someone please look at them, and see how to do them? My schedule
>is becomming too tight to again, and I won't fit it this week. I
>converted about 30% so far, and you can see some of this working at
>
>	http://nothingmuch.woobling.org/beerdb
>
>Important parts are missing.
>
Hey that's kinda cool.

>I just can't eat that TT stuff - it's so ugly, and it uses stuff which
>is just not right to do under Petal.
>
>Something which might resolve the issues I'm having is to port the
>	object/path/?thing
>extension that Zope's implementation has, which interpolates thing into
>the path, and then evaluates the path. This is used extensively under
>Simon Cozens original TT templates.
>
Darn. Could you give a simple TT example? Just so that I can write a 
test and try to get it working.
(Continue reading)

Yuval Kogman | 16 Jun 18:13

Re: Maypole

On Wed, Jun 16, 2004 at 17:01:03 +0100, Jean-Michel Hiver wrote:

> Darn. Could you give a simple TT example? Just so that I can write a 
> test and try to get it working.

in the macros file, under display_line:

	maybe_link_view(item.$col);

which is like

	<span petal:define="object item/?col"/?>
	<span metal:use-macro="macros#maybe_link_view"/>

but is instead replaced with

	FIXME
	

I forgot - a major refactoring is to remove the various defines, and
make the macros use the same object names. Even better would be to
implement METAL slots... ;-)

> HTML Tidy is your friend :)

xmllint even more so, because I remember to use it ;-)

Somewhat related:

Look at the source of http://nothingmuch.woobling.org/beerdb and
(Continue reading)


Gmane