Hi Mason Users!

I've been frustrated with this all morning.  I have a particular spot 
where (presumably) mason is not filling in a variable correctly and so 
a DBI->do call is coming back with *no* return value (it is not undef, 
either).  Here's some prelimary stuff that all works fine:

% my $db = DBI->connect("DBI:SQLite:$db_file");

% #######  Determine how we were called ######
% # add subject to database?
% if (exists $ARGS{name}) { $db->do("insert into subjects (name) values 
('$ARGS{name}');"); }

Then there are other possibilities using if (exists), this is the 
problem one as it *should* be:

% # add docdir to database?
% } elsif (exists $ARGS{title}) {
%     $db->do(<<"DONE");
%          insert into docdirs (title,path,subj_id,pages)  
%          values ('$ARGS{title}','$ARGS{path}',
%               '$ARGS{subjid}','$ARGS{pages}');
%DONE
%}

However, none of these variable is getting filled in altho they are 
testing valid.  Here is what I'm looking at now after such testing:

% # add docdir to database?
% } elsif (exists $ARGS{title}) {
%   my $t=$ARGS{title}; my $p=$ARGS{path}; my $s=$ARGS{subjid}; 
my $n=$ARGS{pages};

%#  my $r=$db->do("insert into docdirs (title,path,subj_id,pages) 
values ('$t','$p','$s','$n');");

%   my $r=$db->do("insert into docdirs (title) values ('$t');");
    <h2><%"($r) $t $p $s $n <-"%></h2>
% }

this contains my attempts to find a solution (eg by assigning tmp 
variables from $ARGS).   I would note that no matter what variable 
value I use (eg, $t="whatever") in the simplified, one value version at 
the bottom, I get nothing.  If I change it to:

%   my $r=$db->do("insert into docdirs (title) values ('whatever');");

Ie, no variable to substitute, then $r is one and "whatever" is 
successfully added to the db.  Again, all the variables do contain 
correct values as verified by the <h2> line. This shows $r as nothing 
(); but $r does not test positive for undef either.

I suspect this has something to do with the order in which Mason 
performs substitutions, but in any case it seems like a real "bug" or 
something to me; the variable is valid and the syntax is identical to 
the syntax I am using elsewhere.  There is no SQL error in the http 
logs.

If I can't find a better solution, I will just have to work around this 
by breaking the page into seperate components -- since all my other db 
insert calls work, the only thing I see different in this page is the 
length and number of (potential) db operations, etc.  Since only one of 
the potential operations will take place, I can't really blame DBI and 
believe the page is just "too much" for mason to correctly parse*.  
That is not a very satisfying solution!

_MK

* all of those other, almost identical ones, work, so I can't blame the 
preceeding syntax either...the last one just appears to be "the straw 
that broke the camel's back" ;)


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to