[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] $Config object is not interpolating inside [perl] tag [MV4]
****** message to minivend-users from "Bill Randle" <billr@exgate.tek.com> ******
Mark,
I don't know why the RHS of your assignment statement isn't working.
I do have an alternate solution for you, using the new mvasp feature
in MV4. It does set the global flag, but only for the block of mvasp
code - not globally.
This is based on some code Mike wrote for the site I'm working on
and seems to work pretty well. [Note: I haven't tested the changes
I made to make it match your variable names, etc.]
[mvasp global=1 tables=user_auth]
<%
no strict;
# lookup desired user(s) from user_auth db
my $dbh = $Sql{user_auth};
my $sth = $dbh->prepare(q{
SELECT username, email
FROM user_auth
WHERE seller.id = user_auth.id
AND seller.id = products.seller_id
AND (products.id = 1
OR products.id = 11)
})
or return error_message("can't open user_auth database");
my $rc = $sth->execute()
#or die $DBI::errstr;
or return HTML("\ncan't open user_auth database");
HTML("\nsth=$sth rc=$rc");
my ($code, $item, $bid, $status, $complete);
while (($username, $email) = $sth->fetchrow()) {
# set custom route info for this user
$Config->{Route_repository}{$username}{email} = $email;
HTML("test: $email<BR>\n");
}
# show all the routes
my $route, $k;
foreach $route (keys %{ $Config->{Route_repository} }) {
my $ucroute = uc($route);
HTML("$ucroute <BR>\n");
foreach $k (keys %{ $Config->{Route_repository}{$route} }) {
HTML("$k => $Config->{Route_repository}{$route}{$k} <BR>\n");
}
HTML("<P>");
}
%>
[/mvasp]
-Bill Randle
billr@exgate.tek.com
On Mar 6, 10:54am, Mark Stosberg wrote:
} Subject: [mv] $Config object is not interpolating inside [perl] tag [MV4]
} ****** message to minivend-users from Mark Stosberg <mark@summersault.com>
******
}
}
} Hello!
}
} I've got a question for the seasoned minivend users out there. I've
} got a situation when some minivend variables inside my [perl] tag are
} clearly being interpolated, and others clearly are not. I can't figure
} this out.
} The good news is that my example below the core of a solution to
} dynamically route to multiple vendors at checkout (using a SQL
} database).
}
} First I'll paste in the code, and then the result I'm getting, and then
} my comments on it.
}
} --------- code --------------------------
}
} [sql type=list sql="select username, email
} from user_auth
} where seller.id = user_auth.id
} and seller.id = products.seller_id
} and (products.id = 1
} or products.id = 11
} );"
} interpolate=1]
}
} <BR>
} [perl interpolate=1]
} $Config->{Route_repository}{"[sql-param username]"}{email} =
} "[sql-param email]";
} $html = "test: [sql-param email]<BR>\n";
} $html;
} [/perl]
}
} [/sql]
}
} <hr>
} [perl]
} # Show all the routes and their details
} my $html;
} foreach my $route (keys %{ $Config->{Route_repository} }) {
} $html .= uc($route)."<BR>\n";
} foreach my $k (keys %{ $Config->{Route_repository}{$route} })
{
} $html .= "$k => $Config->{Route_repository}{$route}{$k}
<BR>\n";
} }
} $html .= "<P>";
} }
} return $html;
} [/perl]
}
} --------- result --------------------------
}
} test: mark@summersault.com
}
} test: mark@stosberg.com
}
} COPY_USER
} cybermode =>
} report => etc/mail_receipt
} track => etc/log
} increment => 0
} encrypt => 0
} attach => 0
} supplant => 0
} empty => 1
}
} LOG
} cybermode =>
} report => etc/log_transaction
} track => etc/log
} increment => 0
} encrypt => 0
} attach => 0
} supplant => 0
} empty => 1
}
} [SQL-PARAM USERNAME]
} email => [sql-param email]
}
} ------- comments -----------
}
}
} So the first thing that happens up there is that I use some custom sql
} to get all the need routing information from my seller table. Currently
} I'm doing this for two fixed products, but I think with a bit of magic,
} I could do it for all the items in a minivend cart.
}
} Second, inside the SQL loop is some perl code. The first line of the
} perl code sticks creates an entry for the dynamic route and it's email
} address in the Route_repository and the second line tests that the
} interpolation is happening as expected (it is!).
}
} Third, I have another perl routine to print out the contents of all the
} current routes. What I find is that my syntax was correct for assigning
} to a route, but the minivend tags weren't interpolated, although they
} were just the line after the $Config call was made!
}
} If there is a good reason why this interpolation isn't happening, is
} there another syntax I could use (short of turning on AllowGlobal, so I
} run SQL with the [perl] tag). I tried a number of alternatives, but the
} $Config line always ended with the non-interpolated version of the data.
} It's as if that line is being fixed at compile time, rather than at run
} time.
}
} Thanks for any ideas!
}
} -mark
}
} --
} <<-------------------------------------------------------------->>
} personal website < Summersault Website Design
} http://mark.stosberg.com/ > http://www.summersault.com/
} -
} 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
}-- End of excerpt from Mark Stosberg
-
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