1 package SGN
::Role
::Site
::Mason
;
4 use namespace
::autoclean
;
10 use Scalar
::Util qw
/blessed/;
12 use HTML
::Mason
::Interp
;
22 =head2 forward_to_mason_view
24 Deprecated. Do not use in new code.
28 # forward_to_mason_view
30 # Usage: $c->forward_to_mason_view( '/some/thing', foo => 'bar' );
31 # Desc : call a Mason view with the given arguments and exit
32 # Args : mason component name (with or without .mas extension),
33 # hash-style list of arguments for the mason component
34 # Ret : nothing. terminates the program afterward.
35 # Side Effects: exits after calling the component
37 # This replaces CXGN::MasonFactory->new->exec( ... )
39 sub forward_to_mason_view
{
41 my ($comp,@args) = @_;
43 if( $ENV{SERVER_SOFTWARE
} && $ENV{SERVER_SOFTWARE
} =~ /HTTP-Request-AsCGI/ ) {
44 print $self->view('Mason')->render( $self, $comp, { %{$self->stash}, @args} );
45 die ["EXIT\n",0]; #< weird thing for working with Catalyst's CGIBin controller
47 croak
"forward_to_mason_view is deprecated, and only works in CGI scripts";
54 Usage: my $string = $c->render_mason( '/page/page_title',
56 Desc : call a Mason component without any autohandlers, just
57 render the component and return its output as a string
58 Args : mason component name (with or without .mas),
59 hash-style list of component arguments
60 Ret : string of component's output
61 Side Effects: none for this function, but the component could
62 access the database, or whatnot
65 print '<div>Blah blah: '.$c->render_mason('/foo').'</div>';
73 return $self->view('BareMason')->render( $self, $view, { %{$self->stash}, @_ } );
76 =head2 clear_mason_tempfiles
78 Usage: $c->clear_mason_tempfiles
79 Desc : delete mason cached tempfiles to force mason components to
80 reload. in normal operation, called only on server restart
82 Ret : nothing meaningful
83 Side Effects: dies on error
86 This is run at app startup as a setup_finalize hook.
90 after
'setup_finalize' => \
&clear_mason_tempfiles
;
92 sub clear_mason_tempfiles
{
95 for my $temp ( $self->path_to( $self->tempfiles_subdir() )->children ) {
96 rmtree
( "$temp" ) if -d
$temp && basename
("$temp") =~ /^mason_cache_/;