[ic] Adding a system wide module

Ethan Rowe ethan at endpoint.com
Mon Jan 31 20:37:48 EST 2005

Jeff Fearn wrote:

>On Mon, 31 Jan 2005 06:37:18 -0800, Ed LaFrance (New Media LLC)
><ic_users at newmediaems.com> wrote:
>>At 09:16 PM 1/30/2005, you wrote:
>>>Hi, I want to allow the Date::Calc modules functions to be used in the
>>>HTML pages on my site. Is there one place I can put this that will
>>>allow it to be run on any store on the server?
>>The best thing to do would be to install the module in your system Perl,
>>though you could also install it locally for Interchange.
>I have Date::Calc installed in the system perl.
>>The you can call
>>it in a GlobalSub or UserTag, and perhaps even in a [perl global=1] block,
>>provided that you have the catalog in the AllowGlobal configuration string.
>Does this mean that I need to write a wrapper for every function I
>wanted to use from Date::Calc?
>I was hoping to be able to bypass the Tag stuff entirely, just using
>[perl] and writting perl code in that on html pages.
>interchange-users mailing list
>interchange-users at icdevgroup.org
The Safe module won't permit use of just any old function from within 
[perl] and [calc] blocks; this is what the AllowGlobal directive 
mentioned above is getting at.  In order to be unrestricted in the use 
of Perl calls (outside of what Interchange permits via Safe), you have 
to use AllowGlobal, and then indicate in the perl block that it should 
operate in global context ([perl global=1], I think).

Safe, by default, will only permit use of $Db, $Sql, $Session, $Values, 
$Scratch, $CGI, $CGI_array, $Tag, $Cfg (and $Row in a forthcoming 
release); I might be missing a couple here...

It is not generally considered advisable to use the AllowGlobal 
directive.  Therefore, while your desire to avoid usertags is perfectly 
understandable, the usertag approach really is your best bet, I would think.

If you can live with somewhat suboptimal performance, I don't think you 
need a different wrapper for every Date::Calc function.  Rather, use a 
single global usertag wrapper, with a function name as its first argument:
UserTag date_calc Order function
UserTag date_calc AddAttr
UserTag date_calc Routine <<EOF
sub {
    my ($function,$opt) = @_;

 From there, you ought to be able to get a reference to the function you 
want to call through the Date::Calc package.  However, I don't know if 
Interchange will permit symbolic references (i.e., it may not like this: 
my $sub = "Date::Calc::$function"; $sub->();).  I think strict refs is 
always active.  Maybe you can get at it via *foo{THING} syntax, though I 
don't know if that will fly either... ( my $sub = 
*{"Date::Calc::$function"}{CODE}; don't know if this syntax will work as 
I haven't ever actually used *foo{THING}...)

Maybe somebody else will pipe up and say that this is an outrageously 
bad idea.  But maybe it isn't, and maybe it's helpful.  I hope so. :)

    - Ethan

Ethan Rowe
End Point Corporation
ethan at endpoint.com

More information about the interchange-users mailing list