steal some code from CGI::Compile, release
[catagits/Catalyst-Controller-WrapCGI.git] / lib / CatalystX / GlobalContext.pm
CommitLineData
32b32c62 1package CatalystX::GlobalContext;
2
3use strict;
4use warnings;
5use parent 'Exporter';
6
7use Scalar::Util 'weaken';
8
457c1d76 9use vars '$c';
10our @EXPORT_OK = '$c';
11
32b32c62 12=head1 NAME
13
14CatalystX::GlobalContext - Export Catalyst Context
15
16=head1 VERSION
17
d5ba2ab2 18Version 0.023
32b32c62 19
20=cut
21
d5ba2ab2 22our $VERSION = '0.023';
32b32c62 23
24=head1 SYNOPSIS
25
26 package MyApp::Controller::Root;
27
28 use CatalystX::GlobalContext ();
29
30 sub auto {
31 my ($self, $c) = @_;
32 CatalystX::GlobalContext->set_context($c);
33 1;
34 }
35
36 package Some::Other::Module;
37
38 use CatalystX::GlobalContext '$c';
39
40 ...
41 do stuff with $c
42 ...
43
44=head1 DESCRIPTION
45
21a20b7e 46This module, in combination with L<Catalyst::Controller::WrapCGI> or
47L<Catalyst::Controller::CGIBin> is for helping you run legacy mod_perl code in
48L<Catalyst>.
32b32c62 49
50You save a copy of $c somewhere at the beginning of the request cycle, and it is
51then accessible through an export where you need it.
52
21a20b7e 53You can then rip out C<Apache::> type things, and replace them with things based on
54C<$c>.
32b32c62 55
21a20b7e 56What we really need is a set of C<Apache::> compatibility classes, but that doesn't
32b32c62 57exist yet.
58
59DO NOT USE THIS MODULE IN NEW CODE
60
61=head1 CLASS METHODS
62
63=head2 CatalystX::GlobalContext->set_context($c)
64
65Saves a weakened reference to the Catalyst context,
66which is accessible from other modules as an export.
67
68=cut
69
70sub set_context {
71 $c = $_[1];
72 weaken $c;
73}
74
21a20b7e 75=head1 SEE ALSO
76
77L<Catalyst::Controller::CGIBin>, L<Catalyst::Controller::WrapCGI>,
78L<Catalyst>
79
32b32c62 80=head1 BUGS
81
82Please report any bugs or feature requests to C<bug-catalyst-controller-wrapcgi
83at rt.cpan.org>, or through the web interface at
84L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Controller-WrapCGI>.
85I will be notified, and then you'll automatically be notified of progress on
86your bug as I make changes.
87
88=head1 SUPPORT
89
90More information at:
91
92=over 4
93
94=item * RT: CPAN's request tracker
95
96L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Controller-WrapCGI>
97
98=item * AnnoCPAN: Annotated CPAN documentation
99
100L<http://annocpan.org/dist/Catalyst-Controller-WrapCGI>
101
102=item * CPAN Ratings
103
104L<http://cpanratings.perl.org/d/Catalyst-Controller-WrapCGI>
105
106=item * Search CPAN
107
108L<http://search.cpan.org/dist/Catalyst-Controller-WrapCGI>
109
110=back
111
efa4a434 112=head1 AUTHOR
113
114See L<Catalyst::Controller::WrapCGI/AUTHOR> and
115L<Catalyst::Controller::WrapCGI/CONTRIBUTORS>.
116
32b32c62 117=head1 COPYRIGHT & LICENSE
118
efa4a434 119Copyright (c) 2008-2009 L<Catalyst::Controller::WrapCGI/AUTHOR> and
120L<Catalyst::Controller::WrapCGI/CONTRIBUTORS>.
32b32c62 121
122This program is free software; you can redistribute it and/or modify it
123under the same terms as Perl itself.
124
125=cut
126
1271; # End of CatalystX::GlobalContext
128
129# vim: expandtab shiftwidth=4 ts=4 tw=80: