[Zope-Perl] Security and CODE
Gisle Aas
gisle@ActiveState.com
26 Mar 2001 12:49:37 -0800
David Kulp <David_Kulp@affymetrix.com> writes:
> My problem: I cannot get Perl scripts to return hash refs. Returning
> references to hashes causes a security violation like
> below (why?).
I'm not sure what the end result about what needed modification to get
the SecurityManager play nice with perl hashes and perl arrays. For
now I suggest avoid returning them if you want Python methods or DTML
to manipulate them. Should be fine if you only pass them through.
> Similar problem with array refs.
>
> Perl script is simple:
>
> my %a = ('a',2);
> return \%a;
You could transform the hash into a python dict by changing the return
statement to be:
return Python::dict(%a);
> DTML is simple:
>
> The value is <dtml-let x="perlref()"><dtml-var expr="x.get('a')"></dtml-let>
>
>
> I've studied the examples on zwiki and I believe I'm doing things
> correctly! I've tried too many minor modifications in syntax, using
> explicit vars, etc., but no dice.
>
> What's even stranger is that I also have an external Perl script that I've
> boiled down at this point to just "return [ 1, 2 ];" and there's a
> corresponding <dtml-let rec="func(...)"><dtml-in rec>...
> and I get the error "Error Type: PerlError. Error Value: Not a CODE
> reference" on the <dtml-in>. I have the same problem if I
> "return { 1, 2 }". No problem at all when just "return 2;" with
> <dtml-let rec="func(...)"><dtml-var rec>.
Returning Python::list() values from the Perl method should work.
--Gisle