WE_Multisite/Root.pm

filter: Statementstmt 30.0% 12 / 40 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 27.1% 16 / 59 CC 7 SCAR 30.3
CC
7
Cov
23%
new
42.0
identify
6.0
init
2.0
CRAP 20.8
« WE/DB/Base.pm ↑ Summary WE/Util/GenericTree.pm »
1 # -*- perl -*-
2  
3 #
4 # $Id: Root.pm,v 1.6 2003/12/16 15:21:23 eserte Exp $
5 # Author: Slaven Rezic
6 #
7 # Copyright (C) 2001 Online Office Berlin. All rights reserved.
8 # Copyright (C) 2002 Slaven Rezic.
9 # This is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License, see the file COPYING.
11  
12 #
13 # Mail: slaven@rezic.de
14 # WWW: http://we-framework.sourceforge.net
15 #
16  
17 package WE_Multisite::Root;
18  
19 =head1 NAME
20  
21 WE_Multisite::Root - a sample implementation for a multi-site environment
22  
23 =head1 SYNOPSIS
24  
25 $root = new WE_Multisite::Root -rootdir => $root_directory_for_database;
26  
27 =head1 DESCRIPTION
28  
29 A sample instantiation for C<WE::DB> for multi-site environments.
30 There is only one UserDB for the whole system, but there is a number
31 of independen site databases (ObjDB and ContentDB).
32  
33 =head1 METHODS
34  
35 =over 4
36  
37 =cut
38  
39 1 ▶use base qw(WE::DB);
Subroutine BEGIN: called CC=1 SCAR=0.0
40 1 ▶use WE::Obj;
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 WE::Obj->use_classes(':all');
43 WE::DB->use_databases(qw/Obj ComplexUser Content OnlineUser Name/);
44  
45 __PACKAGE__->mk_accessors(qw(DBDir Readonly Locking));
46  
47 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
49 $VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/);
50  
51 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
52 0 my($class, %args) = @_;
53 0 my $self = {};
54 0 bless $self, $class;
55  
56 0 my $db_dir = delete $args{-rootdir};
57 0 ▶ die "No db_dir given" if !defined $db_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $db_dir 0 0 0
58 0 $self->DBDir($db_dir);
59 0 ▶ my $readonly = defined $args{-readonly} ? delete $args{-readonly} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'-readonly'} ? : 0 0 0
60 0 ▶ if (!$readonly) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readonly) 0 0 0
61 0 ▶ die "$db_dir is not writable" if !-w $db_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -w $db_dir 0 0 0
62 }
63 0 $self->Readonly($readonly);
64 0 ▶ my $locking = defined $args{-locking} ? delete $args{-locking} : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'-locking'} ? : 0 0 0
65 0 $self->Locking($locking);
66  
67 0 $self->UserDB (WE::DB::ComplexUser->new($self, "$db_dir/userdb.db"));
68 0 $self->OnlineUserDB (WE::DB::OnlineUser->new($self, "$db_dir/onlinedb.db"));
69  
70 0 $self;
71 }
72  
73 0 ▶sub init {
Subroutine init: not called CC=1 SCAR=6.9
74 0 die "XXX Reimplementation needed!";
75 0 my $self = shift;
76 0 $self->SUPER::init(@_);
77 0 my $u = $self->UserDB;
78 }
79  
80 0 ▶sub identify {
Subroutine identify: not called CC=2 SCAR=17.9
81 0 die "XXX should I use CurrentUser or another member for the user directories?";
82 0 my $self = shift;
83 0 my $r = $self->SUPER::identify(@_);
84 0 ▶ if ($r) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r) 0 0 0
85 0 my $user = $self->CurrentUser;
86 0 $self->ObjDB(WE::DB::Obj->new($self, $self->DBDir."/$user/objdb.db",
87 #-serializer => 'Storable',
88 -locking => $self->Locking,
89 -readonly => $self->Readonly,
90 ));
91 0 $self->ContentDB(WE::DB::Content->new($self, $self->DBDir."/$user/content"));
92 0 $self->NameDB(WE::DB::Content->new($self, $self->DBDir."/$user/name.db"));
93 }
94 0 $r;
95 }
96  
97  
98 1;
99  
100 __END__
« WE/DB/Base.pm ↑ Summary WE/Util/GenericTree.pm »