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