[ic] Want to use new module/library in embedded Perl code

Timothy Cassidy 6tc1@qlink.queensu.ca
Wed, 7 Mar 2001 19:09:36 -0500 (EST)


The e-mail that I am referencing in this e-mail can be found immediately
following this e-mail.

When I put this code:
> [perl]
> {
> 	return join '<BR>',@INC,'<BR>';
> }
> [/perl]

into one of my html pages, nothing appeared.  When I checked the source of
the html, the only thing that got generated was a single <BR> tag.

Also when you say
> See bin/interchange for how to use perl modules.
Where do I find this bin/interchange

Also when you state
> See bin/interchange for how to use perl modules.  Just put your JVM module
> there and restart.  Odds are you are not changing that module, right?
I don't understand where you expect me to put my JVM module.  I didn't
think it mattered where I put the source code for the JVM module.  I am
loading the module into the kernel (so far as I understand) and therefore
it should be available to any perl code I execute on this machine.

Sorry for being such a pain, I just didn't think it would be so difficult
to do this once I had the JVM module working for perl on this machine.

Thanks,
Tim

On Thu, 15 Feb 2001 cfm@maine.com wrote:

> On Wed, Feb 14, 2001 at 11:58:00PM -0800, Dan B wrote:
> > At 01:49 AM 2/15/2001 -0500, you wrote:
> > >Hey thanks alot for the advice - I'm now able to call procedures in user
> > >tags, but I still don't seem to be able to "use" my JVM module.  I tried
> > >using the "use" syntax:
> > >
> > >UserTag java_code Routine   <<EOF
> > >sub {
> > >         use JVM;
> > >return "testy testy";
> > >
> > >}
> > >EOF
> > >
> > >But this didn't work and nothing gets reported in my:
> > >/tmp/icdebug
> > >file except for a log of when I restart the server:
> > >Start DEBUG at Thu Feb 15 00:10:50 2001
> > >
> > >Anyway, after that failed, I tried to adapt your shipping subroutine that
> > >you sent me to my purposes:
> > >
> > >UserTag java_code Routine   <<EOF
> > >sub {
> > >         require MV::JVM;
> > >return "testy testy";
> > >
> > >}
> > >EOF
> > >
> > >This also didn't work - is there any sort of a tutorial on the syntax of
> > >writing these subroutines?  Specifically on how to import modules.  Once I
> > >have access to the JVM module, I know the code I need to write in perl.
>
> MV::JVM is probably not going to work for you unless you have a directory
> MV in the @INC.  Ours is /usr/lib/perl5/MV where we keep our custom
> minivend libraries; I doubt you have that.  And unless you run Debian linux
> /usr/lib/perl5 is probably not even in your @INC.
>
> See what your @INC is with something like this:  I'm not sure if it
> runs afoul of Safe in a stock install or not.
> [perl]
> {
> 	return join '<BR>',@INC,'<BR>';
> }
> [/perl]
>
> I'd suggest you NOT use "MV".  There is no reason to clutter your life with
> our legacy code and conventions.
>
> See bin/interchange for how to use perl modules.  Just put your JVM module
> there and restart.  Odds are you are not changing that module, right?
>
>
> > >
> > >Thanks for all of your help,
> > >Tim Cassidy
> >
> > Does it help if you set AllowGlobal mode for your catalog?
>
> You need that sometimes; I don't think it is completely consistent. (We're
> still at 4.03 - YMMV.)
>
>
> >
> > http://developer.akopia.com/cgi-bin/ic/docfly.html?mv_arg=reference24%2e04
> >
> >
> >
> > >On Mon, 12 Feb 2001 cfm@maine.com wrote:
> > >
> > > > > The best I was able to do was create a GlobalSub in the interchange.cfg
> > > > > file:
> > > > >
> > > > > GlobalSub <<EOF
> > > > > sub count_orders {
> > > > > return "this is returned from count_orders subroutine.\n";
> > > > > }
> > > > > EOF
> > > >
> > > > You don't have these modules, but the syntax is the same.
> > > > I'm pretty sure you can "use" (vs "require").
> > > >
> > > >
> > > > #############
> > > > ## merchants_shipping
> > > >
> > > > UserTag merchants_shipping Order base
> > > > UserTag merchants_shipping Routine <<EOF
> > > > sub {
> > > >         require MV::Merchants;
> > > >         require MV::Shipping;
> > > >         my($M,$adj,%opt);
> > > >
> > > >         $opt{config}=$Vend::Cfg->{CatalogName};
> > > >         $adj=0;
> > > >
> > > $M=&MV::Merchants::load_merchant(\%opt,$Vend::Session->{values}); #
> > > stubbed everywhere
> > > >         $opt{shipping_rules}=$M->{$opt{config}}{shipping_rules} if
> > > defined($M);
> > > >
> > > $adj+=&MV::Shipping::base_item_shipping(\%opt,$opt{shipping_rules}) if
> > > ($opt{shipping_rules});
> > > >
> > > $adj+=&MV::Shipping::extra_item_shipping(\%opt,$opt{shipping_rules}) if
> > > ($opt{shipping_rules});
> > > >
> > > $adj+=&MV::Shipping::gift_certificate_shipping(\%opt,$opt{shipping_rules})
> > >   if ($opt{shipping_rules});
> > > >         return $adj;
> > > > }
> > > > EOF
> > > >
> > > > Frankly, I think
> > > > the issue is you are taking too big a first bite.  Write a
> > > > little perl module that just opens, writes and closes a file.
> > > > Call that perl module.  Get it to work.  They are all the same
> > > > after that.
> > > >
> > > > > So then I tried creating a regular subroutine in the interchange.cfg
> > > file:
> > > > > Sub <<EOF
> > > > > sub sort_cart_by_quantity {
> > > > > my $out = 'This is a test!!!';
> > > > > return $out;
> > > > > }
> > > > > EOF
> > > > >
> > > > > But again I couldn't call it from my embedded perl code in my html pages:
> > > > > [perl]
> > > > > return sort_cart_by_quantity();
> > > > > [/perl]
> > > >
> > > > Is that right?  I bet you created a nameless sub that has
> > > > a compiled sub in it, sort_cart_by_quantity.  I'm not sure about
> > > > that Sub syntax in cfg - never used it.  Check Config.pm and see
> > > > how it gets parsed.
> > > >
> > > >
> > > > --
> > > >
> > > > Christopher F. Miller, Publisher                             cfm@maine.com
> > > > MaineStreet Communications, Inc         208 Portland Road, Gray, ME  04039
> > > > 1.207.657.5078                                       http://www.maine.com/
> > > > Content management, electronic commerce, internet integration, Debian linux
> > > >
> > > > _______________________________________________
> > > > Interchange-users mailing list
> > > > Interchange-users@lists.akopia.com
> > > > http://lists.akopia.com/mailman/listinfo/interchange-users
> > > >
> > >
> > >
> > >
> > >_______________________________________________
> > >Interchange-users mailing list
> > >Interchange-users@lists.akopia.com
> > >http://lists.akopia.com/mailman/listinfo/interchange-users
> >
> > Dan Browning, Cyclone Computer Systems, danb@cyclonecomputers.com
> >
> >
> > _______________________________________________
> > Interchange-users mailing list
> > Interchange-users@lists.akopia.com
> > http://lists.akopia.com/mailman/listinfo/interchange-users
>
> --
>
> Christopher F. Miller, Publisher                             cfm@maine.com
> MaineStreet Communications, Inc         208 Portland Road, Gray, ME  04039
> 1.207.657.5078                                       http://www.maine.com/
> Content management, electronic commerce, internet integration, Debian linux
>
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@lists.akopia.com
> http://lists.akopia.com/mailman/listinfo/interchange-users
>