annotate Lib/Configuration.pm @ 8:fffb153be599

DOM Schema
author Sergey
date Tue, 25 Aug 2009 17:36:37 +0400
parents 03e58a454b20
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package Configuration;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4 my $Configured = 0;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
5
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
6 sub import {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
7 my ($class,$site) = @_;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
8
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
9 if ($site and $site ne $Configured) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
10 Configure($site);
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
11 $Configured = $site;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
12 } elsif (not $site and not $Configured) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
13 $Configured = 1;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
14 require Configuration::Global;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
15 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
16 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
17
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18 our %virtualSite;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
19
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
20 sub Configure {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
21 my $siteName = shift;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
22 require Configuration::Global;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
23
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
24 while ( my ($pattern,$configSite) = each %virtualSite) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
25 next if not $siteName =~ $pattern;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
26 if (ref $configSite eq 'CODE') {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
27 $configSite->();
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
28 } elsif (not ref $configSite and $configSite) {
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29 require $configSite;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
30 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
31 last;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
32 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
33 }
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
34
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
35
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
36
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
37 1;