[ic] HTTP POST, getting a bit closer but not there yet

Marc Brevoort interchange-users@icdevgroup.org
Fri Feb 14 07:42:00 2003


On Thu, 2003-02-13 at 20:42, Dan Browning wrote:
> >I've modified this to accept url and content, and tried to get it
> >working as tag and as subroutine included from catalog.cfg, but to my
> >frustration, all I'm getting is "Safe: require trapped by operation
> >mask" anytime I try to 'use LWP::UserAgent'.

> Answer 1:
> <Mike Heins>
 [story snipped]
> I think the only thing would be to ... build the initial object
> at catalog startup time....
> </Mike Heins>

Hm, which object would that be in this case, the URL post object? I'm
not sure I understand how to do this, any pointers?

> Answer 2:  Call the code via usertag or [calc].
>          [tag-that-does-runtime-require]
>          -or-
>          [calc] q{[tag-that-does-runtime-require]} [/calc]

Okay, that overcomes the Safe trap, but now I can't dynamically pass
parameters to the function anymore. The IC list tells that that can
be solved by using $Tag->myusertag($param1,$param2) but then safe mode
starts complaining again :/ Is there any workaround for this?

> Answer 3:  Put it in a global usertag.

If I understand correctly, seemingly there is a difference between
'regular' usertags and global usertags which I'm still missing. A search
on the mailing list for 'global usertag' shows the following:

> Quoting Stefan Hornburg (Racke) (racke@linuxia.de):
> Has anyone an idea why this didn't work:
> UserTag chart Routine <<EOF
> sub {
> 	eval { require GIFgraph::bars;	};
> 	if ($@) {
> 		::logError("Cannot generate chart, GIFgraph module not installed:
$@");
> 		return;
> 	}
> }	
> EOF
> This is a global usertag, so it resembles the get_url UserTag.
> I suppose that I _should_ work, sigh.

Mike shows a problem with $Tag (which I suppose I'll be expecting
because I need to pass parameters dynamically) and a solution, which
ever so subtle differences:

<Mike Heins>
No doubt you are calling it with [perl] $Tag->chart(@parms); [/perl]
Safe will not allow a runtime require, no matter what you do. 	You would
need to do:

UserTag chart Routine <<EOF
eval { require GIFgraph::bars; };
if($@) {
  return sub {
    ::logError("GIFgraph module not installed:$@");
};
}
sub { # Do some stuff with GIFgraph::bars; }
EOF
</Mike Heins>

I've tried several variations on this, but haven't managed to get things
working so far. I guess I could use a shed of light on this: what
exactly makes these two behave so differently?

-- 
Marc Brevoort

e-mail:	marc.brevoort@armazemdedados.com
web:	http://www.armazemdedados.com

Armazem de Dados, Informatica, Lda
Dep. Desenvolvimento
Tel. +351 21 910 83 10 / Fax. +351- 21 910 83 19