brapi refactor error response
[sgn.git] / lib / CXGN / MasonFactory.pm
blob41770c11fb64a17a311c0f188c2e76c880d31e1a
1 =head1 DEPRECATED
3 This package is deprecated, do not use in new code.
5 =cut
7 package CXGN::MasonFactory;
8 use strict;
9 use warnings;
11 use Carp;
13 use CatalystX::GlobalContext '$c';
15 sub _context {
16 return $c || do {
17 require SGN::Context;
18 SGN::Context->instance
22 sub new {
23 my $class = shift;
24 @_ and croak "new() takes no arguments\n";
25 return CXGN::MasonFactory::InterpWrapper->new(
26 context => $class->_context,
30 sub bare_render {
31 my $class = shift;
32 my $comp = shift;
33 my $context = $class->_context;
34 return $context->view('BareMason')->render( $context, $comp, { c => $context, @_ });
37 package CXGN::MasonFactory::InterpWrapper;
38 use Moose;
40 has 'context' => ( is => 'ro', required => 1 );
42 sub exec {
43 my ( $self, $comp, @args ) = @_;
44 my $context = $self->context;
45 print $context->view('Mason')->render( $context, $comp, { c => $context, @args } );
48 __PACKAGE__->meta->make_immutable;
51 __END__
53 # =head1 NAME
55 # CXGN::MasonFactory - a factory that returns HTML::Mason::Interp object configured for the CXGN layout.
57 # =head1 SYNOPSIS
59 # my $mason = CXGN::MasonFactory->new();
60 # $mason->exec('/my/mason/module, %args);
63 # my $output = CXGN::MasonFactory
64 # ->bare_render( '/my/component.mas',
65 # foo => 'bar',
66 # baz => 'boo',
67 # );
69 # =head1 DESCRIPTION
71 # To create a new Mason object, use CXGN::MasonFactory instead of HTML::Mason. MasonFactory will give you correctly set paths for the CXGN system.
73 # =head1 AUTHOR
75 # Lukas Mueller E<lt>lam87@cornell.eduE<gt>
77 # =head1 COPYRIGHT & LICENSE
79 # Copyright (c) 2009 The Boyce Thompson Institute for Plant Research
81 # This program is free software; you can redistribute it and/or modify
82 # it under the same terms as Perl itself.
84 # =head1 METHODS
86 # =cut
87 # =head2 new
89 # Usage: $mason = CXGN::MasonFactory->new()
90 # $mason->exec("/blabla");
91 # Desc: creates an appropriate HTML::Mason object
92 # Args: optional hash-style list as:
93 # data_dir => additional data tempfile dir to add,
94 # ...
96 # See L<HTML::Mason::Admin> and L<HTML::Mason::Interp>
97 # for more an these arguments.
99 # Side Effects: none
100 # Example:
102 # CXGN::MasonFactory->new->exec('/mycomponent.mas');
104 # =cut
107 # =head2 bare_render
109 # Usage: my $output = CXGN::MasonFactory
110 # ->bare_render('/my/component.mas',
111 # foo => 'bar',
112 # baz => 'boo',
113 # );
115 # Desc : use this method to call a mason component like an
116 # html-generating function
117 # Args : component name, then hash-style list of arguments for the
118 # component
119 # Ret : string of HTML produced by the component
120 # Side Effects: throws a warning that the page you are using it in
121 # needs to be migrated to all-mason
122 # Example :
124 # # in some legacy script
126 # print info_section_html(title => 'Clone &amp; library',
127 # collapsible => 1,
128 # contents =>
129 # '<center><table><tr><td>'
130 # . CXGN::MasonFactory
131 # ->bare_render('/genomic/clone/clone_summary.mas',
132 # clone => $clone )
133 # . '</td><td>'
134 # . CXGN::MasonFactory
135 # ->bare_render('/genomic/library/library_summary.mas',
136 # library => $clone->library_object)
137 # . '</td></tr></table>'
138 # . '</center>'
139 # );
141 # =cut