[AppWrap-cvs] AppWrap/Apache/AppWrap Doorknob.pm,1.10,1.11
Status: Beta
Brought to you by:
planetman
From: <pla...@us...> - 2002-12-05 04:05:47
|
Update of /cvsroot/appwrap/AppWrap/Apache/AppWrap In directory sc8-pr-cvs1:/tmp/cvs-serv11735 Modified Files: Doorknob.pm Log Message: fixed bug which was caching phase, cleaned up code Index: Doorknob.pm =================================================================== RCS file: /cvsroot/appwrap/AppWrap/Apache/AppWrap/Doorknob.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Doorknob.pm 1 Dec 2002 01:02:53 -0000 1.10 --- Doorknob.pm 5 Dec 2002 04:05:44 -0000 1.11 *************** *** 7,13 **** # ################################################################# ! # 13 Nov 02. Warnings for uninitialized block ! # 06 Nov 02. Removed call to Subs::get_my_text, because in this phase of the Apache lifecycle we might not know the language ! # 05 Nov 02. Stubbed in initial language-independence code require Exporter; --- 7,14 ---- # ################################################################# ! # 05Dec02. Cleaned up code whilst fixing phase-caching bug ! # 13Nov02. Warnings for uninitialized block ! # 06Nov02. Removed call to Subs::get_my_text, because in this phase of the Apache lifecycle we might not know the language ! # 05Nov02. Stubbed in initial language-independence code require Exporter; *************** *** 19,23 **** use vars qw($VERSION); ! our $VERSION = '0.03'; use strict; --- 20,24 ---- use vars qw($VERSION); ! our $VERSION = '0.04'; use strict; *************** *** 45,60 **** my $log = $r->log; ! my ($t1,$t2); ! my $uri = $r->uri; ! # $uri begins with a slash, so $path[0] is blank ! my @path = split('/', $uri); ! my $table = $path[1]; return DECLINED unless $table; ! #$log->debug("\nDoorknob: got to table: $table"); # use %opts to pass info between subs. &Verify might have set # $r->notes if fields were missing from user input. ! my (%opts, $test); # get the contents of table:my_tables. Its OK that %opts is --- 46,61 ---- my $log = $r->log; ! my $test; ! # get the table and phase. This site presently defines no ! # path components beyond the phase: http://domain/$table/$phase ! my (undef, $table, $phase, undef) = split('/', $r->uri); return DECLINED unless $table; ! #$log->debug("\nDoorknob: got table: $table") if $table; ! #$log->debug("\nDoorknob: got phase: $phase") if $phase; # use %opts to pass info between subs. &Verify might have set # $r->notes if fields were missing from user input. ! my %opts; # get the contents of table:my_tables. Its OK that %opts is *************** *** 64,77 **** # bug out if request is not a valid table name return DECLINED unless exists $my_tables->{$table}; - #$log->debug("\nDoorknob: got past my_tables: $table"); # populate %opts $opts{table} = $table; - $opts{path} = \@path; # determine name of the AppWrap phase in this request, if any. # $phase is simply the second component of the URI, when the # 1st component is a user data table. eg, qw[list display # focus audit calendar generate_form verify confirm] - my $phase = $path[2] if $path[2]; # preload data commonly used by downstream handlers and subs --- 65,75 ---- *************** *** 127,150 **** #$log->debug("\nDoorknob: args: $test"); ! $r->handler( 'perl-script' ); ! # if a handler is defined, set it, then return control to Apache. ! my $handler = $my_tables->{$table}{handler}; ! if ($handler) { ! if ($phase && $phase eq 'download') { ! # if ($path[2] && $path[2] eq 'download') { # need to strip '/download' from the URI leaving only the name ! # of the file ! $r->set_handlers( PerlTransHandler => [ \&Apache::AppWrap::Download_strip::handler ]); ! $r->set_handlers( PerlHandler => [ \&Apache::AppWrap::Download::handler ]); ! } ! else { ! $r->set_handlers( PerlHandler => [ $handler ] ); ! } ! return OK; ! } ! # if we got here no handler is explicitly set, so the switch ! # below will set it ! if ($phase) { ! if ($phase eq 'confirm') { # Do we nee to weed out incomplete and possibly subversive # POSTs? --- 125,148 ---- #$log->debug("\nDoorknob: args: $test"); ! $r->handler( 'perl-script' ); ! # if a handler is defined, set it, then return control to Apache. ! my $handler = $my_tables->{$table}{handler}; ! if ($handler) { ! if ($phase && $phase eq 'download') { # need to strip '/download' from the URI leaving only the name ! # of the file ! $r->set_handlers( PerlTransHandler => [ \&Apache::AppWrap::Download_strip::handler ]); ! $r->set_handlers( PerlHandler => [ \&Apache::AppWrap::Download::handler ]); ! } ! else { ! $r->set_handlers( PerlHandler => [ $handler ] ); ! } ! return OK; ! } ! #$log->debug("\nDoorknob: passed download, phase=$phase") if $phase; ! # if we got here no handler is explicitly set, so the switch ! # below will set it ! if ($phase) { ! if ($phase eq 'confirm') { # Do we nee to weed out incomplete and possibly subversive # POSTs? *************** *** 153,159 **** } # end 'Confirm' elsif ($phase eq 'verify') { ! # this is NOT a PerlHandler, simply a subroutine ! Apache::AppWrap::Subs::reqd_fields(\%opts); ! #$log->debug("\nDoorknob: got to verify"); } elsif ($phase eq 'modify') { --- 151,156 ---- } # end 'Confirm' elsif ($phase eq 'verify') { ! # this is NOT a PerlHandler, simply a subroutine ! Apache::AppWrap::Subs::reqd_fields(\%opts); } elsif ($phase eq 'modify') { *************** *** 191,203 **** elsif ($phase eq 'graph') { $r->set_handlers( PerlHandler => [ \&Apache::AppWrap::Graph::handler ]); ! } # end of graph, end known $path[2] else { ! # unrecognized $path[2], return DECLINED; } ! } # end $path[2] existence else { ! # This is our default. This $path[1] IS defined in my_tables, ! # but there is no $path[2], so run the List::handler. $phase = 'list'; $r->set_handlers( PerlHandler => [ \&Apache::AppWrap::List::handler ]); --- 188,201 ---- elsif ($phase eq 'graph') { $r->set_handlers( PerlHandler => [ \&Apache::AppWrap::Graph::handler ]); ! } # end of graph, end known $phase else { ! # unrecognized $phase return DECLINED; } ! } # end $phase existence else { ! #$log->debug("\nDoorknob: setting default handler."); ! # This is our default. This $table IS defined in my_tables, ! # but there is no $phase so run the List::handler. $phase = 'list'; $r->set_handlers( PerlHandler => [ \&Apache::AppWrap::List::handler ]); *************** *** 205,208 **** --- 203,207 ---- # now preload this last bit $opts{phase} = $phase; + #$log->debug("\nDoorknob: leaving."); return OK; |