From: Chris W. <la...@us...> - 2005-07-04 03:06:06
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16248 Modified Files: Cache.pm Log Message: be able to save non-SPOPS objects in the cache Index: Cache.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Cache.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Cache.pm 3 Jul 2005 16:24:21 -0000 1.14 --- Cache.pm 4 Jul 2005 03:05:54 -0000 1.15 *************** *** 7,10 **** --- 7,11 ---- use OpenInteract2::Constants qw( :log ); use OpenInteract2::Context qw( CTX ); + use Scalar::Util qw( blessed ); $OpenInteract2::Cache::VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/); *************** *** 100,104 **** my $data = $p->{data}; my ( $obj ); ! if ( _is_object( $data ) ) { $obj = $data; $key = _make_spops_idx( ref $obj, $obj->id ); --- 101,105 ---- my $data = $p->{data}; my ( $obj ); ! if ( _is_spops_object( $data ) ) { $obj = $data; $key = _make_spops_idx( ref $obj, $obj->id ); *************** *** 124,128 **** my $key = $p->{key}; ! if ( ! $key and _is_object( $p->{data} ) ) { $key = _make_spops_idx( ref $p->{data}, $p->{data}->id ); } --- 125,129 ---- my $key = $p->{key}; ! if ( ! $key and _is_spops_object( $p->{data} ) ) { $key = _make_spops_idx( ref $p->{data}, $p->{data}->id ); } *************** *** 154,162 **** ! sub _is_object { my ( $item ) = @_; my $typeof = ref $item; ! return undef if ( ! $typeof ); ! return undef if ( $typeof =~ /^(HASH|ARRAY|SCALAR)$/ ); return 1; } --- 155,163 ---- ! sub _is_spops_object { my ( $item ) = @_; my $typeof = ref $item; ! return undef unless ( blessed( $item ) ); ! return undef unless ( $item->isa( 'SPOPS' ) ); return 1; } *************** *** 271,277 **** =item * ! B<data>: The data to save in the cache. This can be an SPOPS object, ! HTML content or any cacheable Perl data structure. (Don't try to store ! database handles, filehandles, or any other object with 'live' connections to real-world resources.) --- 272,278 ---- =item * ! B<data>: The data to save in the cache. This can be an object, HTML ! content or any other cacheable Perl data structure. (Don't try to ! store database handles, filehandles, or any other object with 'live' connections to real-world resources.) |