3 SGN::Context - deprecated, do not use in new code
9 # SGN::Context - configuration and context object, meant to export a
10 # similar interface to the Catalyst context object, to help smooth our
11 # transition to Catalyst.
15 # my $c = SGN::Context->new;
16 # my $c = SGN::Context->instance; # new() and instance() do the same thing
18 # # Catalyst-compatible
19 # print "my_conf_variable is ".$c->get_conf('my_conf_variable');
23 # Note that this object is a singleton, based on L<MooseX::Singleton>.
24 # There is only ever 1 instance of it.
28 # Does: L<SGN::SiteFeatures>, L<SGN::Site>
30 # =head1 OBJECT METHODS
37 use namespace
::autoclean
;
39 use warnings FATAL
=> 'all';
46 use Catalyst
::Utils
();
47 use CatalystX
::GlobalContext
'$c';
49 sub instance
{ shift->new(@_) }
51 # only use this object if $c is not available
52 around
qw( new ) => sub {
57 return $class->$orig(@_);
60 sub setup_finalize
{} #< stubbed out to satisfy roles
63 my ( $self, @relpath ) = @_;
65 @relpath = map "$_", @relpath; #< stringify whatever was passed
67 my $basepath = $self->get_conf('basepath')
68 or die "no base path conf variable defined";
69 -d
$basepath or die "base path '$basepath' does not exist!";
71 return File
::Spec
->catfile( $basepath, @relpath );
76 $class = ref $class if ref $class;
78 return $config{$class} ||= $class->_build_config;
83 my $home = Catalyst
::Utils
::home
( __PACKAGE__
);
91 USERNAME
=> sub { (getpwuid($>))[0] },
93 GROUPNAME
=> sub { (getgrgid($)))[0] },
101 || die "failed to load sgn config files in dir '$home'";
105 SGN::Role::Site::Config
106 SGN::Role::Site::DBConnector
107 SGN::Role::Site::DBIC
108 SGN::Role::Site::Files
109 SGN::Role::Site::Mason
110 SGN::Role::Site::SiteFeatures
113 __PACKAGE__
->meta->make_immutable( inline_constructor
=> 0 );