| 1 | package CatalystX::ASP::Application; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 9 | ▶ | use namespace::autoclean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 9 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 9 | has 'asp' => ( | |||||||||||||
| 7 | is => 'ro', | ||||||||||||||
| 8 | isa => 'CatalystX::ASP', | ||||||||||||||
| 9 | required => 1, | ||||||||||||||
| 10 | weak_ref => 1, | ||||||||||||||
| 11 | ); | ||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 NAME | ||||||||||||||
| 14 | |||||||||||||||
| 15 | CatalystX::ASP::Application - $Application Object | ||||||||||||||
| 16 | |||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||
| 18 | |||||||||||||||
| 19 | use CatalystX::ASP::Application; | ||||||||||||||
| 20 | |||||||||||||||
| 21 | my $application = CatalystX::ASP::Application->new(asp => $asp); | ||||||||||||||
| 22 | $application->{foo} = $bar; | ||||||||||||||
| 23 | |||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||
| 25 | |||||||||||||||
| 26 | Like the C<$Session> object, you may use the C<$Application> object to store | ||||||||||||||
| 27 | data across the entire life of the application. Every page in the ASP | ||||||||||||||
| 28 | application always has access to this object. So if you wanted to keep track of | ||||||||||||||
| 29 | how many visitors there where to the application during its lifetime, you might | ||||||||||||||
| 30 | have a line like this: | ||||||||||||||
| 31 | |||||||||||||||
| 32 | $Application->{num_users}++ | ||||||||||||||
| 33 | |||||||||||||||
| 34 | The Lock and Unlock methods are used to prevent simultaneous access to the | ||||||||||||||
| 35 | C<$Application> object. | ||||||||||||||
| 36 | |||||||||||||||
| 37 | =head1 METHODS | ||||||||||||||
| 38 | |||||||||||||||
| 39 | =over | ||||||||||||||
| 40 | |||||||||||||||
| 41 | =item $Application->Lock() | ||||||||||||||
| 42 | |||||||||||||||
| 43 | Not implemented. This is a no-op. This is unnecessary given the implementation | ||||||||||||||
| 44 | |||||||||||||||
| 45 | =cut | ||||||||||||||
| 46 | |||||||||||||||
| 47 | # TODO: will not implement | ||||||||||||||
| 48 | 1 | ▶ | sub Lock { | ||||||||||||
|
Subroutine
Lock: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 49 | 1 | my ( $self ) = @_; | |||||||||||||
| 50 | 1 | $self->asp->c->log->warn( "\$Application->Lock has not been implemented!" ); | |||||||||||||
| 51 | 1 | return; | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | =item $Application->UnLock() | ||||||||||||||
| 55 | |||||||||||||||
| 56 | Not implemented. This is a no-op. This is unnecessary given the implementation | ||||||||||||||
| 57 | |||||||||||||||
| 58 | =cut | ||||||||||||||
| 59 | |||||||||||||||
| 60 | # TODO: will not implement | ||||||||||||||
| 61 | 1 | ▶ | sub UnLock { | ||||||||||||
|
Subroutine
UnLock: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 62 | 1 | my ( $self ) = @_; | |||||||||||||
| 63 | 1 | $self->asp->c->log->warn( "\$Application->UnLock has not been implemented!" ); | |||||||||||||
| 64 | 1 | return; | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | |||||||||||||||
| 67 | =item $Application->GetSession($sess_id) | ||||||||||||||
| 68 | |||||||||||||||
| 69 | This NON-PORTABLE API extension returns a user C<$Session> given a session id. | ||||||||||||||
| 70 | This allows one to easily write a session manager if session ids are stored in | ||||||||||||||
| 71 | C<$Application> during C<Session_OnStart>, with full access to these sessions | ||||||||||||||
| 72 | for administrative purposes. | ||||||||||||||
| 73 | |||||||||||||||
| 74 | Be careful not to expose full session ids over the net, as they could be used | ||||||||||||||
| 75 | by a hacker to impersonate another user. So when creating a session manager, for | ||||||||||||||
| 76 | example, you could create some other id to reference the SessionID internally, | ||||||||||||||
| 77 | which would allow you to control the sessions. This kind of application would | ||||||||||||||
| 78 | best be served under a secure web server. | ||||||||||||||
| 79 | |||||||||||||||
| 80 | =cut | ||||||||||||||
| 81 | |||||||||||||||
| 82 | 1 | ▶ | sub GetSession { | ||||||||||||
|
Subroutine
GetSession: called CC=3 SCAR=13.6
Pod
documented
| |||||||||||||||
| 83 | 1 | my ( $self, $sess_id ) = @_; | |||||||||||||
| 84 | 1 | my $c = $self->asp->c; | |||||||||||||
| 85 | 1 | my $session_class = ref $self->asp->Session; | |||||||||||||
| 86 | 1 | ▶ | if ( $c->can( 'get_session_data' ) ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 87 | 0 | my $session = $c->get_session_data( $sess_id ); | |||||||||||||
| 88 | 0 | return bless $session, $session_class | |||||||||||||
| 89 | } elsif ( $c->can( 'session_cache' ) ) { | ||||||||||||||
| 90 | 0 | my $session = $c->session_cache->get( $sess_id, existing_session_only => 1 ); | |||||||||||||
| 91 | 0 | return bless $session, $session_class | |||||||||||||
| 92 | } else { | ||||||||||||||
| 93 | 1 | return $self->asp->Session; | |||||||||||||
| 94 | } | ||||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | =item $Application->SessionCount() | ||||||||||||||
| 98 | |||||||||||||||
| 99 | This NON-PORTABLE method returns the current number of active sessions in the | ||||||||||||||
| 100 | application, and is enabled by the C<SessionCount> configuration setting. This | ||||||||||||||
| 101 | method is not implemented as part of the original ASP object model, but is | ||||||||||||||
| 102 | implemented here because it is useful. In particular, when accessing databases | ||||||||||||||
| 103 | with license requirements, one can monitor usage effectively through accessing | ||||||||||||||
| 104 | this value. | ||||||||||||||
| 105 | |||||||||||||||
| 106 | =cut | ||||||||||||||
| 107 | |||||||||||||||
| 108 | # TODO: will not implement | ||||||||||||||
| 109 | 1 | ▶ | sub SessionCount { | ||||||||||||
|
Subroutine
SessionCount: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 110 | 1 | my ( $self ) = @_; | |||||||||||||
| 111 | 1 | $self->asp->c->log->warn( "\$Application->SessionCount has not been implemented!" ); | |||||||||||||
| 112 | 1 | return; | |||||||||||||
| 113 | } | ||||||||||||||
| 114 | |||||||||||||||
| 115 | 0 | ▶ | sub DEMOLISH { | ||||||||||||
|
Subroutine
DEMOLISH: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 116 | 0 | my ( $self ) = @_; | |||||||||||||
| 117 | |||||||||||||||
| 118 | # It's okay if it fails... | ||||||||||||||
| 119 | 0 | eval { $self->asp->GlobalASA->Application_OnEnd }; | |||||||||||||
| 120 | } | ||||||||||||||
| 121 | |||||||||||||||
| 122 | 9 | __PACKAGE__->meta->make_immutable; | |||||||||||||
| 123 | |||||||||||||||
| 124 | =back | ||||||||||||||
| 125 | |||||||||||||||
| 126 | =head1 SEE ALSO | ||||||||||||||
| 127 | |||||||||||||||
| 128 | =over | ||||||||||||||
| 129 | |||||||||||||||
| 130 | =item * L<CatalystX::ASP::Session> | ||||||||||||||
| 131 | |||||||||||||||
| 132 | =item * L<CatalystX::ASP::Request> | ||||||||||||||
| 133 | |||||||||||||||
| 134 | =item * L<CatalystX::ASP::Response> | ||||||||||||||
| 135 | |||||||||||||||
| 136 | =item * L<CatalystX::ASP::Server> | ||||||||||||||
| 137 | |||||||||||||||
| 138 | =back | ||||||||||||||