[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
[mv] Problem passing hash parameters to UserTag routine
****** message to minivend-users from Edvard Majakari <ed@server.mikroneuvos.fi> ******
Problem: I've defined a global subroutine in minivend.cfg like this:
--------------------------------------------------------------------------
# allow use of 'use' and 'require' in catalog mn (required)
AllowGlobal mn
UserTag calc_form AddAttr
UserTag calc_form Interpolate
UserTag calc_form Routine <<EOC
sub {
use Foo::Bank;
my $ref = shift @_;
# routine calc_mac is defined in Foo::Bank
return join("\n", calc_mac($ref));
}
EOC
--------------------------------------------------------------------------
Then, under catalog mn, I have in receipt.html
[calc-form attrib_version=234 attrib_stamp=[value mv_order_number]
attrib_rcv_id=1234aasdf attrib_language=1 attrib_amount=[total-cost]
attrib_kba=01 action=http://foo.bar.com/cgi-bin/magic method=post]
If I run a test script like
--------------------------------------------------------------------------
use Foo::Bank;
my %hash = ( ... ) # key value pairs in a hash
print map { "$_\n" } calc_mac(\%hash)
--------------------------------------------------------------------------
I get a form like
<form>
<input type=hidden name=attrname value=attrval>
...
</form>
where form field names and values are from the hash. This works OK. But
under minivend, I get
<FORM METHOD="" ACTION="">
</FORM> attr1=value1 attr2=value2 ... attr_n=value_n]
That is, all the data which should be inside the form element (as it will
be if I run the script using command line) appears AFTER the closing form
tag. The form is empty, and parameters appear afterwards with the ']'
character in the end.
For what I understand, either my subroutine definition is wrong (in
minivend.cfg, see above), or I do not call the sub right. However, for
testing purposes, I created the sub
UserTag te_pl AddAttr
UserTag te_pl Interpolate
UserTag te_pl Routine <<EOC
sub {
my $ref = shift @_;
return join("<br>\n", map { "$_: $$ref{$_}" } keys %$ref);
}
EOC
and called this in a html page as follows:
[te-pl foo=bar magic=1]
and it worked right. So, sub definitions seem to be similar in structure,
as well as the calling method. However, calc_form doesn't act the same.
I even thought there was some kind of buffering problem (calc_mac creates
html by pushing strings in a list, and after returns a join ("\n",
@list)) and said '$|=1' in the module Foo::Bank. This didn't change
anything.
Please, if you have any ideas why it doesn't work, enlighten me :)
--
# Ed -- amo, ergo sum
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list