Akopia Akopia Services

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

Re: [mv] Accessing variables in perl environment (MV4.04)



Quoting Mike Heins (mikeh@minivend.com):
> 
> Quoting Stefan Hornburg (racke@linuxia.de):
> > > 
> > > Hey folks,
> > > 
> > > I'm encountering the following problem:
> > > 
> > > [currency][perl values]
> > >          my $summe=safe_tag('subtotal');
> > >          return $summe;
> > > [/perl][/currency]
> > > 
> > > The part with "safe_tag('subtotal')" used to work in MV3.14 just
> > > perfectly and now produces an error message:
> > > Safe: Unable to create sub named "*MVSAFE::safe_tag" at (eval 102) line
> > > 2
> > > 
> > > And $Tag->subtotal() didn't work either. It produces the following error
> > > message:
> > > Safe: Can't use string ("") as a subroutine ref while "strict refs" in
> > > use at /usr/local/minivend/lib/Vend/Parse.pm line 797
> > 
> > Try 
> > 
> > $Tag->subtotal ('main');
> > 
> > See the tag reference on subtotal for more information.
> 
> You might also do:
> 
> [perl tables="pricing products"]
> 	$Tag->subtotal();
> [/perl]
> 
> If you have not opened up the database tables beforehand, you will
> get an error.

Actually, it is (sort of) a bug. The multi-products-database thing
causes Safe errors (even if you only have one products table).

Patch attached and added to Interchange.

-- 
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.8220 fax 7501 <heins@akopia.com>

I have a cop friend who thinks he ought be able to give a new ticket;
"too dumb for conditions".
*** /r/Data.pm	Tue Sep  5 16:39:07 2000
--- /rt/Data.pm	Sun Sep 10 16:31:12 2000
***************
*** 295,302 ****
  	return database_field($Vend::Cfg->{OnlyProducts}, $field_name, $code)
  		if $Vend::Cfg->{OnlyProducts};
  	my ($db);
!     $db = product_code_exists_ref($code, $base || undef);
!     return "" unless $db = product_code_exists_ref($code, $base || undef);
      return "" unless defined $db->test_column($field_name);
      return $db->field($code, $field_name);
  }
--- 295,302 ----
  	return database_field($Vend::Cfg->{OnlyProducts}, $field_name, $code)
  		if $Vend::Cfg->{OnlyProducts};
  	my ($db);
!     $db = product_code_exists_ref($code, $base || undef)
! 		or return '';
      return "" unless defined $db->test_column($field_name);
      return $db->field($code, $field_name);
  }
***************
*** 1290,1303 ****
  
  sub item_price {
  	my($item, $quantity, $noformat) = @_;
! #::logDebug("item_price: " . ::uneval(\@_));
  	return $item->{mv_cache_price}
  		if ! $quantity and defined $item->{mv_cache_price};
  	my ($price, $base, $adjusted);
  	$item = { 'code' => $item, 'quantity' => ($quantity || 1) } unless ref $item;
! 	$base = product_code_exists_ref($item->{code}, $item->{mv_ib})
  		or $Vend::Cfg->{OnFly}
  		or return undef;
  	$price = database_field($base, $item->{code}, $Vend::Cfg->{PriceField})
  		if $Vend::Cfg->{PriceField};
  	$price = chain_cost($item,$price || $Vend::Cfg->{CommonAdjust});
--- 1290,1305 ----
  
  sub item_price {
  	my($item, $quantity, $noformat) = @_;
! #::logDebug("item_price: " . ::uneval_it(\@_));
  	return $item->{mv_cache_price}
  		if ! $quantity and defined $item->{mv_cache_price};
  	my ($price, $base, $adjusted);
  	$item = { 'code' => $item, 'quantity' => ($quantity || 1) } unless ref $item;
! 	if(! $item->{mv_ib}) {
! 		$base = product_code_exists_tag($item->{code}, $item->{mv_ib})
  			or $Vend::Cfg->{OnFly}
  			or return undef;
+ 	}
  	$price = database_field($base, $item->{code}, $Vend::Cfg->{PriceField})
  		if $Vend::Cfg->{PriceField};
  	$price = chain_cost($item,$price || $Vend::Cfg->{CommonAdjust});

Search for: Match: Format: Sort by: