Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1 cgi::cache and file uploads

open
nobody
None
5
2006-04-23
2006-04-23
sprize
No

Not sure if folks frequent this forum but if you see
this and can/do
help, I'd be much obliged

I am trying to implement caching in a cgi app I am
writing for my
company and am having trouble when an attachment is
uploaded as a part
of the multipart form. This is the error that I get.

Can't store GLOB items at ../../lib/Storable.pm
(autosplit into
../../lib/auto/Storable/_freeze.al) line 287, at
/usr/local/perl587/lib/site_perl/5.8.7/CGI/Cache.pm
line 251

Here's how I am setting up my Cache.

CGI::Cache::setup( { cache_options =>
{ cache_root =>
'/tmp/CGI_Cache',
namespace =>
'myapp_cgi',

directory_umask => 077,
max_size => 20
* 1024 * 1024,

default_expires_in => '12 hours',
}
} );
my $c = new CGI;
my $params = $c->Vars;
delete $params->{'uploaded_file'};
CGI::Cache::set_key( $params );
CGI::Cache::invalidate_cache_entry() if $c->param(
'force_regenerate' )
eq 'true';
CGI::Cache::start() or exit;

As you can see up here, I even tried to not include the
upload_file
parameter as a part of the key bu that didnt help. I
also tried to put
CGI::Cache::pause() and CGI::Cache::continue() around
the sub that
performs the upload in the app but that didnt help either.

Any ideas/suggestions would be much appreciated.

regards,
Sam

Discussion

  • David Coppit
    David Coppit
    2006-05-24

    Logged In: YES
    user_id=11103

    Hi Sam,

    Judging from the error message, I'm guessing there's a
    filehandle in your $params. You might want to use
    Data::Dumper to dump $params to see what the culprit is.

    BTW, please let me know the resolution. I can perhaps avoid
    this problem, or at least document it and fail gracefully. I
    can't seem to reproduce the problem here. This is what I'm
    using:

    #!/usr/bin/perl

    use CGI::Cache;
    use CGI;

    use strict;

    CGI::Cache::setup( { cache_options =>
    { cache_root => '/tmp/CGI_Cache',
    namespace => 'myapp_cgi',
    directory_umask => 077,
    max_size => 20 * 1024 * 1024,
    default_expires_in => '12 hours',
    }
    } );

    my $c = new CGI;
    my $params = $c->Vars;
    delete $params->{'uploaded_file'};
    CGI::Cache::set_key( $params );
    CGI::Cache::invalidate_cache_entry()
    if $c->param( 'force_regenerate' ) eq 'true';
    CGI::Cache::start() or exit;

    print $c->header,
    $c->start_form,
    $c->filefield('uploaded_file','starting value',50,80),$c->p,
    $c->checkbox('force_regenerate',0,'true','Force Regenerate'),
    $c->p,
    $c->submit,
    $c->end_form,
    $c->hr;

    print "CGI version: ", $CGI::VERSION, $c->p;

    if ($c->param()) {
    my $params = $c->Vars;
    use Data::Dumper;
    print Dumper $params;
    }