[Petal] Petal 0.84 released

Daniel Fisher dan at webslingerz.com
Mon Feb 10 10:56:09 GMT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

| What URI have you assigned to the TAL and petal: namespaces?
| I am assuming that you have assigned the TAL namespace to Petal's
| namespace URI.  In this case, Petal no longer associates the petal:
| namespace with itself!
|
| I generally set petal:attribute attributes to some dummy value, assign
| the Petal namespace URI to something like 'xmlns:meta' and use the
| aliased 'meta:attribute' to replace both 'xmlns:petal' and
'petal:attribute'
| using a string: construct.
|
| For example:
|
| <test xmlns:meta="http://purl.org/petal/1.0/"
| xmlns:petal="http://purl.org/petal/1.0/willBeReplaced"
| meta:attributes="xmlns:petal string:http://purl.org/petal/1.0/">
|
| <input type='hidden'
| petal:attributes="value willBeReplaced"
| meta:attributes="name configuration/get_identity_field_name;
|   petal:attributes string:value
| entry/${configuration/get_identity_field_name}"
|  />
| </test>
|
| In this case, Petal processes the meta-template using the 'meta:'
namespace,
| replacing the 'xmlns:petal' attribute in the 'test' element, and both the
| 'name' and 'petal:attributes' attributes in the 'input' element.  When
| processing
| the resulting template, Petal uses the usual petal: namespace.

Even though I've been using this technique for a week-or-so, I'm still
amazed that this works. Elegant namespace support is cool (and rare-ish
in Perl projects that I've encountered)!

| I think that there may be a problem with the bugfix that I submitted.
| It appears that Petal has already replaced the inline syntax in the
| attribute value with the PI syntax used internally before the attribute
| is XML encoded and written to the output.  After processing your
| meta-template I get the following for the 'input' element:
|
| <input petal:attributes="value entry/&lt;?var
| name=&quot;configuration/get_identity_field_name&quot;?&gt;;"
type="hidden"
| name="id" />
|
| I need to track this down further.  I thought that the logic around
| the code that I added had already assured that the attribute was
| truly static, without interpolation operators, however I seem to
| have been mistaken ;-)

The PI issue is the problem that I had encountered.

I didn't send it in as a PI error because:
1) I wasn't sure if this was proper behavior for Petal, so I figured I'd
ask first.
2) They were hard to get to without changing my 'metatemplates' to
something that doesn't work

Anyway, I have a (very) little test script/file that works under 0.83,
but not under 0.84. I've tried to emulate the testing conventions used
in other Petal test scripts...

Thank you for your time,
Dan

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8ckt http://www.ipgpp.com/
Comment: Using PGP with Mozilla - http://enigmail.mozdev.org

iQA/AwUBPkfLmARI2Y45X/bvEQKcigCgmIGA4zrJ4RI3uc5OEAZsfv/L6mkAniUJ
wXmrc1tQ+BcTTnuFXizmzeyk
=xPC7
-----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webarch.co.uk/pipermail/petal/attachments/20030210/431ff669/manipulate.htm
-------------- next part --------------
#!/usr/bin/perl

package Configuration;

sub new {
	return bless({}, shift);
}

sub get_identity_field_name {
	return 'id';
}

use Test;
BEGIN { print "1..2\n"; }
END { print "not ok 1\n" unless $loaded;}
use Petal;
$loaded = 1;
print "ok 1\n";

my $template = new Petal('manipulate.html');
$template->process(
	configuration => Configuration->new()
) =~ m!<input petal:attributes="value entry/id;" type="hidden" name="id">!msg ?
	print "ok 2\n" : print "not ok 2\n";




More information about the Petal mailing list