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