r21754 - in /trunk/libpetal-perl: ./ debian/ lib/ lib/Petal/ lib/Petal/Hash/ lib/Petal/TranslationService/ t/ t/data/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Mon Jun 16 18:59:11 UTC 2008
Author: gregoa
Date: Mon Jun 16 18:59:11 2008
New Revision: 21754
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=21754
Log:
New upstream release (closes: #445640).
Added:
trunk/libpetal-perl/t/094_notfalse.t
- copied unchanged from r21753, branches/upstream/libpetal-perl/current/t/094_notfalse.t
trunk/libpetal-perl/t/096_oddeven.t
- copied unchanged from r21753, branches/upstream/libpetal-perl/current/t/096_oddeven.t
trunk/libpetal-perl/t/097_cache_only.t
- copied unchanged from r21753, branches/upstream/libpetal-perl/current/t/097_cache_only.t
trunk/libpetal-perl/t/098_multiple-attributes.t
- copied unchanged from r21753, branches/upstream/libpetal-perl/current/t/098_multiple-attributes.t
trunk/libpetal-perl/t/data/multiple-attributes.xml
- copied unchanged from r21753, branches/upstream/libpetal-perl/current/t/data/multiple-attributes.xml
trunk/libpetal-perl/t/data/notfalse.xml
- copied unchanged from r21753, branches/upstream/libpetal-perl/current/t/data/notfalse.xml
trunk/libpetal-perl/t/data/oddeven.xml
- copied unchanged from r21753, branches/upstream/libpetal-perl/current/t/data/oddeven.xml
Modified:
trunk/libpetal-perl/Changes
trunk/libpetal-perl/MANIFEST
trunk/libpetal-perl/META.yml
trunk/libpetal-perl/Makefile.PL
trunk/libpetal-perl/debian/changelog
trunk/libpetal-perl/lib/Petal.pm
trunk/libpetal-perl/lib/Petal/Cookbook.pod
trunk/libpetal-perl/lib/Petal/Hash.pm
trunk/libpetal-perl/lib/Petal/Hash/Var.pm
trunk/libpetal-perl/lib/Petal/TranslationService/MOFile.pm
trunk/libpetal-perl/t/054_Opt_cache.t
Modified: trunk/libpetal-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/Changes?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/Changes (original)
+++ trunk/libpetal-perl/Changes Mon Jun 16 18:59:11 2008
@@ -1,4 +1,13 @@
Revision history for Petal.
+
+2.19 Fri Jun 16 15:22:00 2006
+ - alias false: modifier as not: to match TALES spec (Jonathan Vanasco)
+ - fix repeat/odd documentation bug and add to cookbook (Jonathan Vanasco)
+ - pod typos (sarabob)
+ - CACHE_ONLY option (Jonathan Vanasco)
+ - Add Digest::MD5 dependency (aaron)
+ - Allow passing arguments to coderefs
+ - Encoding support for gettext mo/po files (Andrew Rodland)
2.18 Tue Jan 17 13:01:00 2006
- $Petal::CodeGenerator::PI_RE should be applied newline insensitively
Modified: trunk/libpetal-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/MANIFEST?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/MANIFEST (original)
+++ trunk/libpetal-perl/MANIFEST Mon Jun 16 18:59:11 2008
@@ -98,6 +98,10 @@
t/091_attribute-newline.t
t/092_on-error.t
t/093_translate.t
+t/094_notfalse.t
+t/096_oddeven.t
+t/097_cache_only.t
+t/098_multiple-attributes.t
t/benchmark.pl
t/data/access_obj_array.html
t/data/access_obj_hash.html
@@ -168,6 +172,7 @@
t/data/metal_self_include.xml
t/data/metal_use_macro.xml
t/data/method_param.xml
+t/data/multiple-attributes.xml
t/data/multiple_includes/includes/footer.tmpl
t/data/multiple_includes/includes/header.tmpl
t/data/multiple_includes/register_form.tmpl
@@ -176,6 +181,8 @@
t/data/nbsp.html
t/data/nested_modifiers/test1.xml
t/data/nested_modifiers/test2.xml
+t/data/notfalse.xml
+t/data/oddeven.xml
t/data/omit-tag.xml
t/data/pass_variables/attributes.html
t/data/pass_variables/content.html
Modified: trunk/libpetal-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/META.yml?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/META.yml (original)
+++ trunk/libpetal-perl/META.yml Mon Jun 16 18:59:11 2008
@@ -1,13 +1,14 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Petal
-version: 2.18
+version: 2.19
version_from: lib/Petal.pm
installdirs: site
requires:
+ Digest::MD5:
MKDoc::XML: 0.72
Scalar::Util: 1.07
Test::Harness: 2.00
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+generated_by: ExtUtils::MakeMaker version 6.30
Modified: trunk/libpetal-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/Makefile.PL?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/Makefile.PL (original)
+++ trunk/libpetal-perl/Makefile.PL Mon Jun 16 18:59:11 2008
@@ -8,6 +8,7 @@
'Test::Harness' => '2.00',
'Scalar::Util' => '1.07',
'MKDoc::XML' => '0.72',
+ 'Digest::MD5' => '',
},
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Petal.pm', # retrieve abstract from module
Modified: trunk/libpetal-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/debian/changelog?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/debian/changelog (original)
+++ trunk/libpetal-perl/debian/changelog Mon Jun 16 18:59:11 2008
@@ -1,4 +1,4 @@
-libpetal-perl (2.18-2) UNRELEASED; urgency=low
+libpetal-perl (2.19-1) UNRELEASED; urgency=low
* Take over for the Debian Perl Group with maintainer's permission
(http://lists.debian.org/debian-perl/2008/06/msg00039.html)
@@ -9,6 +9,8 @@
<rafl at debian.org>); Florian Ragwitz <rafl at debian.org> moved to
Uploaders.
* Add debian/watch.
+
+ * New upstream release (closes: #445640).
-- gregor herrmann <gregoa at debian.org> Sun, 15 Jun 2008 16:49:53 +0200
Modified: trunk/libpetal-perl/lib/Petal.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/lib/Petal.pm?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/lib/Petal.pm (original)
+++ trunk/libpetal-perl/lib/Petal.pm Mon Jun 16 18:59:11 2008
@@ -95,13 +95,17 @@
our $MEMORY_CACHE = 1;
+# cache only mode
+our $CACHE_ONLY = 0;
+
+
# prevents infinites includes...
our $MAX_INCLUDES = 30;
our $CURRENT_INCLUDES = 0;
# this is for CPAN
-our $VERSION = '2.18';
+our $VERSION = '2.19';
# The CodeGenerator class backend to use.
@@ -137,6 +141,7 @@
my $file = shift (@ARGV);
local $Petal::DISK_CACHE = 0;
local $Petal::MEMORY_CACHE = 0;
+ local $Petal::CACHE_ONLY = 0;
local $Petal::INPUT = $ENV{PETAL_INPUT} || 'XML';
local $Petal::OUTPUT = $ENV{PETAL_OUTPUT} || 'XHTML';
print ${Petal->new ($file)->_canonicalize()};
@@ -151,6 +156,7 @@
my $file = shift (@ARGV);
local $Petal::DISK_CACHE = 0;
local $Petal::MEMORY_CACHE = 0;
+ local $Petal::CACHE_ONLY = 0;
print Petal->new ($file)->_code_disk_cached;
}
@@ -163,6 +169,7 @@
my $file = shift (@ARGV);
local $Petal::DISK_CACHE = 0;
local $Petal::MEMORY_CACHE = 0;
+ local $Petal::CACHE_ONLY = 0;
print Petal->new ($file)->_code_with_line_numbers;
}
@@ -241,6 +248,7 @@
sub error_on_undef_var { exists $_[0]->{error_on_undef_var} ? $_[0]->{error_on_undef_var} : $ERROR_ON_UNDEF_VAR }
sub disk_cache { exists $_[0]->{disk_cache} ? $_[0]->{disk_cache} : $DISK_CACHE }
sub memory_cache { exists $_[0]->{memory_cache} ? $_[0]->{memory_cache} : $MEMORY_CACHE }
+sub cache_only { exists $_[0]->{cache_only} ? $_[0]->{cache_only} : $CACHE_ONLY }
sub max_includes { exists $_[0]->{max_includes} ? $_[0]->{max_includes} : $MAX_INCLUDES }
@@ -341,6 +349,7 @@
local $ERROR_ON_UNDEF_VAR = defined $self->{error_on_undef_var} ? $self->{error_on_undef_var} : $ERROR_ON_UNDEF_VAR;
local $DISK_CACHE = defined $self->{disk_cache} ? $self->{disk_cache} : $DISK_CACHE;
local $MEMORY_CACHE = defined $self->{memory_cache} ? $self->{memory_cache} : $MEMORY_CACHE;
+ local $CACHE_ONLY = defined $self->{cache_only} ? $self->{cache_only} : $CACHE_ONLY;
local $MAX_INCLUDES = defined $self->{max_includes} ? $self->{max_includes} : $MAX_INCLUDES;
local $INPUT = defined $self->{input} ? $self->{input} : $INPUT;
local $OUTPUT = defined $self->{output} ? $self->{output} : $OUTPUT;
@@ -369,6 +378,8 @@
die "\$hash is undefined\n\n" unless $hash;
$res = $coderef->($hash);
};
+
+ if ( $CACHE_ONLY == 1 ){ return 1; }
if (defined $@ and $@) { $res = $self->_handle_error ($@) }
elsif (defined $TranslationService && $CURRENT_INCLUDES == 1) { $res = Petal::I18N->process ($res) }
@@ -764,7 +775,7 @@
local $Petal::OUTPUT = 'XHTML';
my $template = new Petal ('foo.xhtml');
- template->process ( my_var => some_object() );
+ $template->process ( my_var => some_object() );
some_object() is a subroutine that returns some kind of object, may it be a scalar,
object, array referebce or hash reference. Let's see what we can do...
@@ -847,11 +858,15 @@
my $template = new Petal ( file => 'hello_world', lang => 'fr-CA' );
print $template->process ( my_var => some_object() );
-What will happen is that the C<$template> object will try to find a file named
-C<fr-CA>, then C<fr>, then will default to <en>. It should work fine for
-includes, too!
-
-NOTE: There is now beta support for ZPT-like i18n attributes, which should
+What will happen is that the C<$template> object will look in the
+C<hello_world> directory and try to find a file named C<fr-CA.xhtml>, then
+C<fr.xhtml>, then will default to C<en.xhtml>. It works fine for includes, too!
+
+These internationalized templates can have whatever file-extension you like,
+Petal searches on the first part of the filename. So you can call them
+C<fr.html>, C<fr.xml>, C<fr.xhtml> or use whatever convention suits you.
+
+NOTE: There is now support for ZPT-like i18n attributes, which should
provide a much nicer framework. See L<Petal::I18N> for details.
@@ -960,6 +975,13 @@
If set to C<false>, Petal will not use the C<Petal::Cache::Memory> module.
+=head2 cache_only => I<true> | I<false> (default: I<false>)
+
+If set to C<true>, Petal will return true after having compiled a template into
+perl code and a subroutine , and optionally using disk_cache or memory_cache if
+either is set.
+
+
=head2 max_includes => I<number> (default: 30)
The maximum number of recursive includes before Petal stops processing. This
@@ -970,7 +992,8 @@
If this option is true, when Petal cannot process a template it will
output lots of debugging information in a temporary file which you can
-inspect.
+inspect. The location for this file is wherever File::Spec->tmpdir()
+specifies as a temp directory (usually /tmp on a unix system).
=head2 encode_charset => I<charset> (default: undef)
@@ -1049,6 +1072,11 @@
<tag tal:repeat="element_name EXPRESSION">
blah blah blah
</tag>
+
+Why?
+
+Repeat statements are used to loop through a list of values,
+typically to display the resulting records of a database query.
Example:
@@ -1079,7 +1107,7 @@
>
<tr
class="odd"
- tal:condition="true: audience/odd"
+ tal:condition="repeat/odd"
>
<td>
This a odd row, it comes before the even row.
@@ -1087,7 +1115,7 @@
</tr>
<tr
class="even"
- tal:condition="true: audience/even"
+ tal:condition="repeat/even"
>
<td>
This a even row.
@@ -1096,11 +1124,38 @@
</div>
</table>
-Why?
-
-Repeat statements are used to loop through a list of values,
-typically to display the resulting records of a database query.
-
+I<repeat> is a local temporary object that only exists within a
+petal:repeat loop. It has a bunch of methods useful for selecting
+different positions in the loop:
+
+=head3 repeat/index
+
+I<index> returns the numeric position of this item within the loop, starts with
+one not zero.
+
+=head3 repeat/number
+
+I<number> is an alias for I<index>.
+
+=head3 repeat/even
+
+I<even> is true if the position is even (0, 2, 4 ...)
+
+=head3 repeat/odd
+
+I<odd> is true is the position is odd (1, 3, 5 ...)
+
+=head3 repeat/start
+
+I<start> is true if this is the first item.
+
+=head3 repeat/end
+
+I<end> is true if this is the last item.
+
+=head3 repeat/inner
+
+I<inner> is true if this is not the I<start> or I<end>.
=head2 attributes
@@ -1696,6 +1751,10 @@
Otherwise, subsequent calls will resume at step 6, until the source template
changes.
+If you are using the mod_perl prefork MPM, you can precompile Petal templates
+into Apache's shared memory at startup by using the cache_only option. This
+will allow you to run through steps 1-7 without passing any data to Petal.
+
=head1 DECRYPTING WARNINGS AND ERRORS
Modified: trunk/libpetal-perl/lib/Petal/Cookbook.pod
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/lib/Petal/Cookbook.pod?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/lib/Petal/Cookbook.pod (original)
+++ trunk/libpetal-perl/lib/Petal/Cookbook.pod Mon Jun 16 18:59:11 2008
@@ -223,6 +223,35 @@
</table>
See L<Petal::Utils|Petal::Utils> for more information.
+
+Alternatively, this can be done entirely with TAL (contributed by Jonathan
+Vanasco):
+
+ <div tal:repeat="row rows">
+ <tag tal:omit-tag="string:1" tal:condition="repeat/even"><tag
+ tal:define="rowClass string:rowEven" tal:omit-tag="string:1"/></tag>
+ <tag tal:omit-tag="string:1" tal:condition="repeat/odd"><tag
+ tal:define="rowClass string:rowOdd" tal:omit-tag="string:1"/></tag>
+ <div
+ tal:attributes="class rowClass"
+ >
+ This will use either the rowEven or rowOdd class. All of the 'tag'
+ elements are omitted on render. This uses a nested define tag in a
+ condition tag, because define precedes condition in order of operations.
+ </div>
+ <div>
+
+The simplest way to do odd/even rows may to duplicate the code entirely for
+each type or row, though this may cause maintenance headaches:
+
+ <table>
+ <tr tal:repeat="emp employees">
+ <td tal:condition="repeat/odd" class="odd" tal:content="emp/name">Employee Name</td>
+ <td tal:condition="repeat/even" class="even" tal:content="emp/name">Employee Name</td>
+ ...
+ </tr>
+ </table>
+
=head1 ADVANCED
Modified: trunk/libpetal-perl/lib/Petal/Hash.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/lib/Petal/Hash.pm?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/lib/Petal/Hash.pm (original)
+++ trunk/libpetal-perl/lib/Petal/Hash.pm Mon Jun 16 18:59:11 2008
@@ -70,6 +70,7 @@
return not $hash->fetch ("true:$variable");
};
+$MODIFIERS->{'not:'} = $MODIFIERS->{'false:'};
# encode: modifier (deprecated stuff)
$MODIFIERS->{'encode:'} = sub {
Modified: trunk/libpetal-perl/lib/Petal/Hash/Var.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/lib/Petal/Hash/Var.pm?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/lib/Petal/Hash/Var.pm (original)
+++ trunk/libpetal-perl/lib/Petal/Hash/Var.pm Mon Jun 16 18:59:11 2008
@@ -96,8 +96,11 @@
elsif (isa ($current, 'HASH'))
{
ACCESS_HASH:
+ unless (isa $current->{$next}, 'CODE')
+ {
confess "Cannot access hash at '$current_path' with parameters (near $argument)"
if ($has_args and not $has_path_tokens);
+ }
$current = $current->{$next};
}
elsif (isa ($current, 'ARRAY'))
@@ -127,7 +130,7 @@
return '';
}
- $current = (isa ($current, 'CODE')) ? $current->() : $current;
+ $current = (isa ($current, 'CODE')) ? $current->(@args) : $current;
$current_path .= "/$next";
}
Modified: trunk/libpetal-perl/lib/Petal/TranslationService/MOFile.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/lib/Petal/TranslationService/MOFile.pm?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/lib/Petal/TranslationService/MOFile.pm (original)
+++ trunk/libpetal-perl/lib/Petal/TranslationService/MOFile.pm Mon Jun 16 18:59:11 2008
@@ -1,5 +1,6 @@
package Petal::TranslationService::MOFile;
use Locale::Maketext::Gettext;
+use Encode;
use strict;
use warnings;
@@ -24,6 +25,8 @@
my $self = bless { file => $file }, $class;
$self->{lexicon} = { read_mo ($file) };
+
+ ($self->{encoding}) = $self->{lexicon}{""} =~ /^Content-Type: text\/plain; charset=(.*)$/im;
return $self;
}
@@ -35,7 +38,9 @@
$self->{lexicon} || return;
my $res = $self->{lexicon}->{$id};
- return $res;
+ return undef unless defined $res;
+
+ return decode($self->{encoding}, $res);
}
Modified: trunk/libpetal-perl/t/054_Opt_cache.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libpetal-perl/t/054_Opt_cache.t?rev=21754&op=diff
==============================================================================
--- trunk/libpetal-perl/t/054_Opt_cache.t (original)
+++ trunk/libpetal-perl/t/054_Opt_cache.t Mon Jun 16 18:59:11 2008
@@ -3,7 +3,7 @@
# Tests the 'disk_cache' and 'memory_cache' options to Petal->new.
#
-use Test::More tests => 8;
+use Test::More tests => 12;
use warnings;
use lib 'lib';
@@ -73,3 +73,33 @@
ok($template->memory_cache, "memory_cache option turns it on again");
+
+# Confirm cache_only defaults to off
+
+$template = new Petal (file => $file, base_dir => $data_dir);
+
+ok(!$template->cache_only, "cache_only defaults to off");
+
+
+# Confirm option can enable it
+
+$template = new Petal (file => $file, base_dir => $data_dir, cache_only => 1);
+
+ok($template->cache_only, "cache_only option turns it on");
+
+
+# Confirm global can enable it
+
+$Petal::CACHE_ONLY = 1;
+$template = new Petal (file => $file, base_dir => $data_dir);
+
+ok($template->cache_only, "\$Petal::CACHE_ONLY turns it on");
+
+
+# Confirm option can disable it
+
+$template = new Petal (file => $file, base_dir => $data_dir, cache_only => 0);
+
+ok(!$template->cache_only, "cache_only option turns it off again");
+
+
More information about the Pkg-perl-cvs-commits
mailing list