AxKit-App-TABOO

 view release on metacpan or  search on metacpan

lib/AxKit/App/TABOO.pm  view on Meta::CPAN

package AxKit::App::TABOO;

our $VERSION = '0.52';

use 5.7.3;
use strict;
use warnings;

use Session;
use Apache;
use Apache::Cookie;
use Apache::Request;
use AxKit;

sub session_config {
  my $r = shift;
  my $prefix = $r->dir_config( 'TABOOPrefix') || 'TABOO';
  my %session_config = (
			Store     => $r->dir_config( $prefix . 'DataStore' ) || 'DB_File',
			Lock      => $r->dir_config( $prefix . 'Lock' ) || 'Null',
			Generate  => $r->dir_config( $prefix . 'Generate' ) || 'MD5',
			Serialize => $r->dir_config( $prefix . 'Serialize' ) || 'Storable'
		       );
   
  # When using Postgres, a different default is needed.  
  if ($session_config{'Store'} eq 'Postgres') {
    $session_config{'Commit'} = 1;
    $session_config{'Serialize'} = $r->dir_config( $prefix . 'Serialize' ) || 'Base64'
  }

  
  # Load session-type specific parameters, comma-separated, name => value pairs
  foreach my $arg ( split( /\s*,\s*/, $r->dir_config($prefix . 'Args'))) {
    my ($key, $value) = split( /\s*=>\s*/, $arg );
    $session_config{$key} = $value;
  }

  return %session_config;
}

sub session {
  my $r = shift;
  my $req = Apache::Request->instance($r);
  my $vid = $req->param('VID');
  unless ($vid) { # Then look in the cookie
    my $cookies = Apache::Cookie->fetch;
    my $tmp = $cookies->{'VID'};
    return undef unless defined($tmp);
    $vid = $tmp->value;
    return undef unless ($vid); # No session key
  }
  AxKit::Debug(9, "User's visitor ID: $vid");
  return new Session $vid, session_config($r);
}
    

sub authlevel {
  my $session = shift;
  if (defined($session)) {
    return $session->get('authlevel');
  } else {
    return 0;
  }
}

sub loggedin {
  my $session = shift;
  if (defined($session)) {
    return $session->get('loggedin');
  } else {
    return 'guest';
  }
}

1;
__END__


=head1 NAME

AxKit::App::TABOO - Object Oriented Publishing Framework for AxKit

=head1 INTRODUCTION

AxKit::App::TABOO is a object oriented approach to creating a
publishing system on the top of AxKit, the XML Application Server. 
The two O's thus stands for Object Oriented, AB for AxKit-Based. 
I don't know what the T stands for yet, suggestions are welcome! 

This file holds only a few session and authentication functions, that
I didn't quite knew where to put. This may change.


=head1 DESIGN PHILOSOPHY

There are three main ideas that forms the basis for TABOO:

=over

=item 1. The data should be abstracted to objects so that the AxKit
things never have to deal with where and how the data are stored. 

=item 2. URIs should be sensible and human-readable, reflect what kind
of content you will see, and easy to maintain and independent of
underlying server code.



( run in 0.999 second using v1.01-cache-2.11-cpan-39bf76dae61 )