AW: [ic] GlobalSub Question

Peter peter at pajamian.dhs.org
Thu Apr 26 03:04:43 EDT 2007


On 04/25/2007 11:30 PM, Lars Tode wrote:
> It is Interchange 5.4.0, the latest stable release.

The latest stable is 5.4.2

> By the way, the second GlobalSub produce following messages:
> Global symbol "$Session" requires explicit package name at (eval 16)
> line 18, <GLOBAL> line 80.
> Global symbol "$Tag" requires explicit package name at (eval 16) line
> 25, <GLOBAL> line 80.
> Global symbol "$Values" requires explicit package name at (eval 16) line
> 30, <GLOBAL> line 80.

$Session, $Tag and $Values are only valid for catalog-level subs, for
global subroutines you should use $Vend::Session $Vend::Tags and
$::Values respectively.

> I'm suprised that it ist not possible to access Interchange variables
> within a GlobalSub.
> 
> The reason of using the GlobalSub instead of Sub is, that I have
> problems to access the database using the %Db hash.

You probably need to open the tables.  You can use something like:

$Tag->perl({table => 'products userdb'});

After a line like that you should be able to access the products and
userdb tables via the Db hash.

For a globalsub you have to get a db record in a different way.

> I have written a UserTag, for the CartTrigger, that should store
> informations in the database. If the Tag is called within an Interchange
> Template, it works fine. If it was calles in a Sub (that is used for the
> trigger), the access to the database failed.
> 
> Any ideas?

Yes, because the page you access on probably opened the table before you
accessed it with the usertag, but the sub was called sooner before
anything else opened it.

Peter



More information about the interchange-users mailing list