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 | |
9 | =head1 NAME |
10 | |
11 | CatalystX::GlobalContext - Export Catalyst Context |
12 | |
13 | =head1 VERSION |
14 | |
15 | Version 0.01 |
16 | |
17 | =cut |
18 | |
19 | our $VERSION = '0.01'; |
20 | |
21 | =head1 SYNOPSIS |
22 | |
23 | package MyApp::Controller::Root; |
24 | |
25 | use CatalystX::GlobalContext (); |
26 | |
27 | sub auto { |
28 | my ($self, $c) = @_; |
29 | CatalystX::GlobalContext->set_context($c); |
30 | 1; |
31 | } |
32 | |
33 | package Some::Other::Module; |
34 | |
35 | use CatalystX::GlobalContext '$c'; |
36 | |
37 | ... |
38 | do stuff with $c |
39 | ... |
40 | |
41 | =head1 DESCRIPTION |
42 | |
43 | This module, in combination with L<Catalyst::Controller::WrapCGI> is for helping |
44 | you run legacy mod_perl code in L<Catalyst>. |
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 | |
49 | You can then rip out Apache:: type things, and replace them with things based on |
50 | $c. |
51 | |
52 | What we really need is a set of Apache:: compatibility classes, but that doesn't |
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 | |
71 | =head1 AUTHOR |
72 | |
73 | Rafael Kitover, C<< <rkitover at cpan.org> >> |
74 | |
75 | =head1 BUGS |
76 | |
77 | Please report any bugs or feature requests to C<bug-catalyst-controller-wrapcgi |
78 | at rt.cpan.org>, or through the web interface at |
79 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Controller-WrapCGI>. |
80 | I will be notified, and then you'll automatically be notified of progress on |
81 | your bug as I make changes. |
82 | |
83 | =head1 SUPPORT |
84 | |
85 | More information at: |
86 | |
87 | =over 4 |
88 | |
89 | =item * RT: CPAN's request tracker |
90 | |
91 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Controller-WrapCGI> |
92 | |
93 | =item * AnnoCPAN: Annotated CPAN documentation |
94 | |
95 | L<http://annocpan.org/dist/Catalyst-Controller-WrapCGI> |
96 | |
97 | =item * CPAN Ratings |
98 | |
99 | L<http://cpanratings.perl.org/d/Catalyst-Controller-WrapCGI> |
100 | |
101 | =item * Search CPAN |
102 | |
103 | L<http://search.cpan.org/dist/Catalyst-Controller-WrapCGI> |
104 | |
105 | =back |
106 | |
107 | =head1 COPYRIGHT & LICENSE |
108 | |
109 | Copyright (c) 2008 Rafael Kitover |
110 | |
111 | This program is free software; you can redistribute it and/or modify it |
112 | under the same terms as Perl itself. |
113 | |
114 | =cut |
115 | |
116 | 1; # End of CatalystX::GlobalContext |
117 | |
118 | # vim: expandtab shiftwidth=4 ts=4 tw=80: |