Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

[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


Search for: Match: Format: Sort by: