Architecturally, Its Apache 2.2, Mason 1.33, mod_perl 2.0.2. Like
all good coders should I put the non-display code in reasonably OO PMs
and 'use' it in the mason template. I set up test scripts for each sub
and test they as best I can. In fact, once I started having issues with
this object, I set it up to run a million times and had no failures
from the script on several attempts.
The object is pretty simple. It takes a path as an argument and
returns either a list of directories or file names as urls. Departments
use ftp to upload documents and reports to the directory structure and
then this web app allows others to read them. The base URL is hardcoded
in the PM and there are regexes to avoid spoofing, it seems pretty rock
solid. the issue is that the longer the server is up, the more often it
falsely returns an object with no URLs. Dumping the document, I see
that some of the fields are not defaults, but prints at various points
in the method don't print. This is where I noticed that it appears to
be caching... I noticed some things in the dumped object are from
earlier iterations of the object.
If anyone has a good idea why this is happening or suggestions on
how to debug it, I would sure appreciate this.
The code is below
JimB
#! /usr/local/perl
package Dir;
use strict;
Dir.pm:
sub get_list
{
my $self = ();
shift;
$self->{base} = "/usr/local/www/uploads/SS7";
$self->{URI} = shift;
$self->{path} = "";
$self->{title} = "";
$self->{leaf} = "false";
$self->{names} = ();
$self->{urls} = ();
bless($self);
$self->{title} = $self->{URI};
$self->{path} = $self->{base} . $self->{URI} . "/";
opendir DH, $self->{path};
my @save_files;
while (my $line = readdir(DH))
{
my $path = $self->{path} . $line;
if ((-d $path) && ($line !~ /\.$/))
{
$self->{names}{$line} = $line;
$self->{names}{$line} =~ tr/_/ /d;
$self->{urls}{$line} = $line;
}
else
{
push (@save_files, $line);
}
}
my $count = scalar (keys %{$self->{names}});
if ($count == 0)
{
foreach my $line (@save_files)
{
next if (-d $line);
$self->{names}{$line} = $line;
$self->{names}{$line} =~ tr/_/ /d;
$self->{names}{$line} =~ tr/.xls//d;
$self->{urls}{$line} = $line;
}
$self->{leaf} = "true";
}
return($self);
}
1;
Reports.cgi:
% if (defined $rep->{title}) {
% $rep->{title} =~ tr/_/ /;
% $rep->{title} =~ tr/\// /;
<h3><& SELF:title &><font size="-1">
<% $rep->{title} %></font></h3>
% } else {
<h3><& SELF:title &> </h3>
% }
<ul class="menulist">
% if ($rep->{leaf} eq "true") {
% my %tmp_names = ();
% my %tmp_urls = ();
% foreach $iter (sort {$b cmp $a} keys %{$rep->{urls}}) {
% if ($rep->{names}->{$iter} =~/(\d\d)(\d\d)(\d\d)/) {
% $tmp_names{"$3$1$2"} = $mos[$1] . " $2, 20$3";
% $tmp_urls{"$3$1$2"} = $rep->{urls}->{$iter};
% }
% } foreach $iter (sort {$b <=> $a} keys %tmp_names) {
<li> <a href=""> <% $tmp_names{$iter}
%></a>
% } } else {
% foreach $iter (sort {$b cmp $a} keys %{$rep->{urls}}) {
<li> <a href=""/" . $rep->{urls}->{$iter}
%>&app=SS7/Reports"> <% $rep->{names}->{$iter}
%></a>
% }
% }
</ul>
</div>
<%method title>
SS7:
</%method>
<%once>
use Apps::SS7::Dir;
use Data::Dumper;
</%once>
<%init>
my @mos =
("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec");
my $item;
my $iter;
my $rep = Dir->get_list($ARGS{rep});
</%init>
|
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users