| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Maypole::Virtual::Application; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26004
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
40
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# for now, get this from beerdb.riverside-cms.co.uk |
|
7
|
1
|
|
|
1
|
|
823
|
use Maypole::Application 2.10 (); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.01; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Maypole::Virtual::Application - create multiple Maypole apps on the fly |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package BeerDB; |
|
20
|
|
|
|
|
|
|
use strict; |
|
21
|
|
|
|
|
|
|
use warnings; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Class::DBI::Loader::Relationship; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Maypole::Virtual::Application; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Maypole::Virtual::Application->install_packages( qw( -Debug AutoUntaint ) ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# beer for everyone! |
|
30
|
|
|
|
|
|
|
sub virtual_packages { map { __PACKAGE__ . "::Site$_" } 1 .. 100 } |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub initialize_package |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
|
|
|
|
|
|
my ( $self, $package ) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$package =~ /(Site\d+)$/; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $site = $1; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $username = My::Config::System->get_beerdb_username_for( $site ); |
|
41
|
|
|
|
|
|
|
my $password = My::Config::System->get_beerdb_password_for( $site ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$package->setup( "dbi:mysql:BeerDB$site", |
|
44
|
|
|
|
|
|
|
$username, |
|
45
|
|
|
|
|
|
|
$password, |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$package->config->{template_root} = '/home/beerdb/www/www/htdocs'; |
|
49
|
|
|
|
|
|
|
$package->config->{uri_base} = '/'; |
|
50
|
|
|
|
|
|
|
$package->config->{rows_per_page} = 10; |
|
51
|
|
|
|
|
|
|
$package->config->{display_tables} = [ $package->config->loader->tables ]; |
|
52
|
|
|
|
|
|
|
$package->config->{application_name} = 'The Beer Database'; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$package->auto_untaint; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$package->config->loader->relationship( $_ ) for ( |
|
57
|
|
|
|
|
|
|
'a brewery produces beers', |
|
58
|
|
|
|
|
|
|
'a style defines beers', |
|
59
|
|
|
|
|
|
|
'a pub has beers on handpumps', |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# this would get called anyway during the first request, but |
|
63
|
|
|
|
|
|
|
# putting it here is useful under mod_perl to get all initialisation |
|
64
|
|
|
|
|
|
|
# done before forking off child servers |
|
65
|
|
|
|
|
|
|
$package->init; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub my_custom_request_method |
|
69
|
|
|
|
|
|
|
{ |
|
70
|
|
|
|
|
|
|
# all virtual apps inherit from this package (BeerDB in this case), |
|
71
|
|
|
|
|
|
|
# so methods defined here are inherited by all Maypole request objects |
|
72
|
|
|
|
|
|
|
# in the virtual apps. |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Use this class to setup multiple applications 'on the fly'. This might be useful in a mod_perl |
|
80
|
|
|
|
|
|
|
virtual hosting environment, where you want to give each site its own version of a Maypole |
|
81
|
|
|
|
|
|
|
application. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 METHODS |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item install_packages( @plugins ) |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Pass the list of plugins and flags to be installed in each application, just as with L. |
|
90
|
|
|
|
|
|
|
This method then |
|
91
|
|
|
|
|
|
|
uses the C callback to get a list of package names to install, installs |
|
92
|
|
|
|
|
|
|
each package using L, and runs the |
|
93
|
|
|
|
|
|
|
C callback to configure each package. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub install_packages |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
|
|
|
|
|
|
my ( $class, @plugins ) = @_; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $caller = caller(0); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
foreach my $package ( $caller->virtual_packages ) |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
|
|
|
|
|
|
eval "{ package $package; Maypole::Application->import( qw( @plugins ) ) }"; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
die "Error creating virtual Maypole app $package: $@" if $@; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
{ |
|
112
|
|
|
|
|
|
|
no strict 'refs'; |
|
113
|
|
|
|
|
|
|
unshift @{"$package\::ISA"}, $caller; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$caller->initialize_package( $package ); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 Maypole::Application |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
There's a bug in L that needs to be fixed before using |
|
123
|
|
|
|
|
|
|
this module. You can download a fixed version of C from C, |
|
124
|
|
|
|
|
|
|
until the patch is incorporated in L proper. |
|
125
|
|
|
|
|
|
|
That version of C also works with L (as well as the other L frontends). The build script should check for version 2.10, as does the main package, |
|
126
|
|
|
|
|
|
|
so you should install the patched C before attempting to install this. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
David Baird, C<< >> |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 BUGS |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
135
|
|
|
|
|
|
|
C, or through the web interface at |
|
136
|
|
|
|
|
|
|
L. |
|
137
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
138
|
|
|
|
|
|
|
your bug as I make changes. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Copyright 2005 David Baird, All Rights Reserved. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
147
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; # End of Maypole::Virtual::Application |