Re: columns not getting updated with Class::DBI::FromCGI

[prev] [thread] [next] [Date index for 2005/01/08]

From: Peter Speltz
Subject: Re: columns not getting updated with Class::DBI::FromCGI
Date: 04:08 on 08 Jan 2005
Just a thought -- 
Did you declare your untaint_columns?

I don't see any
 __PACKAGE__->untaint_columns( . . . ) declarations. 





> Howdy!
> 
> I've got a problem that has been giving me too much grief to solve
> on my own.  I am using Class::DBI::FromCGI to update columns from post
> data.  The fun part is when I submit the values only to find a few
> columns have been updated while the others stay the same.  There
> are no errors or warning messages thrown.  Some of my column names
> are mix case.  But those aren't necessarily the ones that don't 
> get updated, there are a few all lower-case columns that don't update.
> 
> I would be ecstatic if this was just some silly overlook on my part.
> 
> I hate to post all my code, so I'll see if I can't just post what's
> relevant (though still a bit of text...):
> 
> 
> # Module in question...
>   package MSI::Admin::person;
> 
>   push @ISA, 'MSI::Admin::DBI';
> 
>   use Class::DBI::FromCGI;
>   use Class::DBI::AsForm;
> 
>   use MSI::Admin::DBI;
>   use base 'MSI::Admin::DBI';
> 
>   MSI::Admin::person->table('person');
> 
>   MSI::Admin::person->columns(All => qw/
>     id searchName firstName middleName lastName nickName title department
> active status
>   /);
> 
>   MSI::Admin::person->has_many(contactInfo => 'MSI::Admin::contactInfo');
>   MSI::Admin::person->has_many(groupMembership =>
> 'MSI::Admin::groupMembership');
>   MSI::Admin::person->untaint_columns(
>     printable => [qw/
>       searchName firstName middleName lastName nickName department
>     /],
>     integer   => [qw/id/]
>   );
>   
>   
> 
> # Mason template used for testing (only the init code, nothing else
> matters)...
>   # $class:  record type to be saved
>   # $id:     record number to save
>   <%init>
>     push @INC, '/www/dws/cgi-bin/lib';
> 
>     use Data::Dumper;
> 
>     use CGI::Untaint;
>     use strict;
>     eval("use $class");
> 
>     my %args = $m->request_args;
> 
>     my $h = CGI::Untaint->new(\%args);
>     my $obj;
> 
>     if(ref $id) {
>       $id = $id->[0];
>     }
> 
>     unless($obj = $class->retrieve($id)) {
>       $obj = $class;
>     }
> 
>     my $recordSaved = 0;
>     my $recordCreated = 0;
> 
>     if($args{'action'} eq 'save') {
>       if($id eq '') {
>         $obj = $class->create_from_cgi($h);
>         $recordCreated = 1;
>       } else {
>         $obj->update_from_cgi($h);
>         $obj->update();
>         $recordSaved = 1;
>       }
>     } elsif($args{'action'} eq 'delete') {
>       $obj->delete();
>     }
>   </%init>
>  
>   
> 
> And finally, here is some output (with notes) from that mason template:
>   RECORD SAVED
>   Form Post Data (From %args)
> 
>   department =        Chemistry
>   status =            Non-Academic Staff
>   __config =      
>   save =              Save
>   url =               personForm.tmpl?id=2
>   lastName =          Scriven
>   id =    2
>   _ERR =        
>   nickName =          Scribbles
>   firstName =         Loyd
>   value =             Chemistry
>   active =            1
>   middleName =        Elmo
>   action =            save
>   class =             MSI::Admin::person
>   title =             Mr.
>   __loaded =          HASH(0x9344b18)
>    
> 
>   Record Data (AFTER it's been updated using update_from_cgi
>                Note: this is the same data that was in the record in the
> first place)
> 
>   firstname =    
>   department =  Chemistry (<- only this column gets updated)
>   nickname =   
>   middlename =        
>   status =      Research Associate
>   active =      0
>   title =  
>   lastname =      
>   searchname =   
>   id =          2
>  
> 
>   Errors (From Class:DBI:FromCGI)
> 
>  
> 
>   CGI::Untaint Vars (using CGI::Untaint manually)
> 
>   department =        Chemistry
>   Error(?): 
>   status =            Non-Academic Staff
>   Error(?): 
>   __config =  
>   Error(?):           No parameter for '__config'
>   save =              Save
>   Error(?): 
>   url =               personForm.tmpl?id=2
>   Error(?): 
>   lastName =          Scriven
>   Error(?): 
>   id =                2
>   Error(?): 
>   _ERR =  
>   Error(?): 
>   nickName =          Scribbles
>   Error(?): 
>   firstName =         Loyd
>   Error(?): 
>   value =             Loyd
>   Error(?): 
>   active =            1
>   Error(?): 
>   middleName =        Elmo
>   Error(?): 
>   action =            save
>   Error(?): 
>   class =             MSI::Admin::person
>   Error(?): 
>   title = Mr.
>   Error(?): 
>   __loaded =          HASH(0x9344b18)
>   Error(?): 
>   
>  
> ----
> Luke 
> 


=====
pjs


		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 

Re: columns not getting updated with Class::DBI::FromCGI
Peter Speltz 04:08 on 08 Jan 2005

Generated at 12:15 on 16 Jan 2005 by mariachi v0.52