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