Hi Gerald et al,

Not sure if this is a bug or me simply making assumptions about how
EmbperlObject would work ...

I've built a Content Management System using EmbperlObject that is
working really well. But one issue I've run into is where an
EmbperlObject "publishing" page does an EmbperlObject::Execute to
publish some target to static html. The behaviour I wasn't expecting is
that after the Execute the containing page's Embperl data structures -
e.g. $req, %fdat, %ENV etc. - contain the published pages data i.e.
looks like these are all globals that just get clobbered by the embedded
Execute.

I've worked around this by just saving and restoring what I'm interested
in, but I'm wondering whether it's feasible for EmbperlObject to handle
this more gracefully? 

I've attached an example page demonstrating the issue - you'll have to
tweak the Execute call for your local install, of course.

Cheers,
Gavin

<html><body>
<h1>Nested EmbperlObject::Executes</h1>
[- $req = shift; $p = $fdat{p}; -]

[$ sub dumphash $]
[- $ref = shift; -]
<table border="0">
[$ foreach $key (sort keys %$ref) $]
<tr><th align="left" valign="top">[+ $key +]</th><td>
[$ if (ref $ref->{$key} eq 'HASH') $]
[$ foreach $key2 (sort keys %{$ref->{$key}}) $]
[+ "$key2 -> $ref->{$key}->{$key2}" +]<br>
[$ endforeach $]
[$ else $]
[+ $ref->{$key} +]
[$ endif $]
</td></tr>
[$ endforeach $]
</table>
[$ endsub $]

[$ if ($p) $]
Published version.
[-
$req->{PUBLISHED} = 1;
$ENV{PUBLISHED} = 1;
-]
[$ else $]

<h3>$req:</h3>
[- dumphash $req -]

<h3>%ENV:</h3>
[- dumphash \%ENV -]

<h3>%fdat:</h3>
[- dumphash \%fdat -]

<h3>EmbperlObject::Execute:</h3>
[# Do another EmbperlObject Execute #]
<pre>
[+
my $fdat = { p => 1, t => 'blue' };
# publishCheckpoint($req, \%fdat);
HTML::EmbperlObject::Execute({
  inputfile => "/opt/web/ewok/htdocs/test/execute2.html",
  output => \$new,
  fdat => $fdat,
  param => $param,
  options => $ENV{EMBPERL_OPTIONS},
  object_base => $ENV{EMBPERL_OBJECT_BASE},
  object_stopdir => "/opt/web/ewok/htdocs",
  object_addpath => "/opt/web/ewok/htdocs/templates;/opt/web/ewok/htdocs",
});
# publishRestore($req, \%fdat);
$new
+]
</pre>

<h3>$req:</h3>
[- dumphash $req -]

<h3>%ENV:</h3>
[- dumphash \%ENV -]

<h3>%fdat:</h3>
[- dumphash \%fdat -]

[$ endif $]
</body></html>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to