Changeset 92
- Timestamp:
- 12/21/09 19:57:32 (3 years ago)
- Files:
-
- trunk/MANIFEST (modified) (2 diffs)
- trunk/lib/Mungo.pm (modified) (2 diffs)
- trunk/lib/Mungo/Response.pm (modified) (4 diffs)
- trunk/t/19-filename.t (added)
- trunk/t/htdocs/19-filename (added)
- trunk/t/htdocs/19-filename/one-level.asp (added)
- trunk/t/htdocs/19-filename/stringy.asp (added)
- trunk/t/htdocs/19-filename/two-level.asp (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/MANIFEST
r85 r92 123 123 t/htdocs/13-errors/compile-use.asp 124 124 t/htdocs/13-errors/compile-use-source-dump.asp 125 126 125 t/16-cache-compiled.t 127 126 t/htdocs/16-cache-compiled/echo-compile-time.asp … … 137 136 t/htdocs/18-quiet/bad-use.asp 138 137 t/htdocs/18-quiet/mungo-error-doc.txt 138 t/19-filename.t 139 t/htdocs/19-filename/one-level.asp 140 t/htdocs/19-filename/two-level.asp 141 t/htdocs/19-filename/stringy.asp trunk/lib/Mungo.pm
r82 r92 245 245 use Apache2::RequestRec; 246 246 use Apache2::RequestUtil; 247 use Apache2::Const qw ( OK NOT_FOUND DECLINED );247 use Apache2::Const qw ( OK NOT_FOUND DECLINED SERVER_ERROR); 248 248 "; 249 249 if($@) { … … 428 428 } 429 429 430 sub CurrentFile { 431 my $self = shift; 432 my @file_stack; 433 434 # Unwind the stack. Each time we hit a package whose name 435 # begins with Mungo::FilePage, demangle the name and push onto our list. 436 my $frame_count = 0; 437 while (my @frame = caller($frame_count)) { 438 $frame_count++; 439 my $package = $frame[0]; 440 if ($package =~ /Mungo::(File|Mem)Page/) { 441 my $awkwardly_built_string = $self->demangle_name($package . '::__content'); 442 $awkwardly_built_string =~ s{Mungo::(File|Mem)Page\((.+)\)}{$2}; 443 push @file_stack, $awkwardly_built_string; 444 } 445 } 446 print STDERR "have file_stack:\n" . Dumper(\@file_stack); 447 448 return wantarray() ? @file_stack : $file_stack[0]; 449 } 430 450 431 451 # Private? trunk/lib/Mungo/Response.pm
r82 r92 30 30 $Response->AddHeader('header_name' => $value); 31 31 %> 32 33 <!-- path of the current file (handy for debugging) --> 34 <% my $file = $Response->CurrentFile(); %> 35 32 36 33 37 <!-- Halt processing and jump out of the handler --> … … 98 102 use Mungo::Utils; 99 103 use HTML::Entities; 104 use Apache2::Const qw ( OK NOT_FOUND DECLINED SERVER_ERROR); 105 100 106 our $AUTOLOAD; 101 107 … … 196 202 } 197 203 204 =head2 $file = $Response->CurrentFile(); 205 206 =head2 @nested_files = $Response->CurrentFile(); 207 208 Returns the path on the filesystem from which the currently executing Mungo code originated. In the second form, the call stack is unwound, and all files are returned, with the deepest-nested one first. 209 210 If the Mungo code originated from a string reference rather than a file, the file entry will read 'ANON'. 211 212 =cut 213 214 sub CurrentFile { 215 my $self = shift; 216 return $self->{Mungo}->CurrentFile(); 217 } 218 198 219 =head2 $Response->i18nHandler($coderef); 199 220 … … 367 388 print '<pre>'.Dumper($@).'</pre>'; 368 389 } 390 391 # Set response code to 500. Fixes trac16 392 $self->{Mungo}->{data}->{ApacheResponseCode} = SERVER_ERROR; 369 393 } 370 394
