view release on metacpan or search on metacpan
lib/Apache/Voodoo.pm view on Meta::CPAN
$Apache::Voodoo::Engine::debug->error(@_);
}
}
sub exception {
my $self = shift;
if (ref($Apache::Voodoo::Engine::debug)) {
$Apache::Voodoo::Engine::debug->exception(@_);
}
Apache::Voodoo::Exception::RunTime::Thrown->throw(join("\n",@_));
}
sub trace {
my $self = shift;
if (ref($Apache::Voodoo::Engine::debug)) {
$Apache::Voodoo::Engine::debug->trace(@_);
}
}
lib/Apache/Voodoo.pm view on Meta::CPAN
sub set_view {
$_[1]->{_view_} = $_[2];
}
sub stop_chain {
$_[1]->{_stop_chain_} = 1;
}
sub redirect {
shift;
Apache::Voodoo::Exception::Application::Redirect->throw(target => shift);
}
sub display_error {
shift;
my ($c,$e,$t);
if (@_ == 3) {
($c,$e,$t) = @_;
}
elsif (@_ >= 2 && $_[0] =~ /^\s*[\w:\.-]+\s*$/) {
$c = shift;
$e = shift;
$t = shift || '/index';
}
else {
$c = '500';
$e = shift;
$t = shift || '/index';
}
if (ref($t)) {
Apache::Voodoo::Exception::Application::DisplayError->throw(
code => $c,
error => $e,
detail => $t
);
}
else {
Apache::Voodoo::Exception::Application::DisplayError->throw(
code => $c,
error => $e,
target => $t
);
}
}
sub access_denied {
shift;
my $m = shift || "Access Denied";
my $t = shift || "/access_denied";
if (ref($t)) {
Apache::Voodoo::Exception::Application::AccessDenied->throw(
error => $m,
detail => $t
);
}
else {
Apache::Voodoo::Exception::Application::AccessDenied->throw(
error => $m,
target => $t
);
}
}
sub raw_mode {
my ($self,$c,$d,$h) = @_;
Apache::Voodoo::Exception::Application::RawData->throw(
"content_type" => $c,
"data" => $d,
"headers" => $h
);
}
sub history {
my $self = shift;
my $session = shift;
my $index = shift;
lib/Apache/Voodoo/Debug/FirePHP.pm view on Meta::CPAN
$v .= '|'.$part.'|';
# \ on the end of the line, on all but the last part
$v .= '\\' if ($i < ($c-1));
$self->setHeader('X-Wf-1-'.$structure_index.'-1-'.$self->{'messageIndex'}, $v);
$self->{'messageIndex'}++;
if ($self->{'messageIndex'} > 99999) {
#throw new Exception('Maximum number (99,999) of messages reached!');
}
}
}
#$self->setHeader('X-Wf-1-Index',$self->{'messageIndex'}-1);
return 1;
}
sub setHeader() {
lib/Apache/Voodoo/Debug/html/debug.js view on Meta::CPAN
text=text.replace(cx,
function(a) {
return '\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);
}
);
}
if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))) {
j = eval('('+text+')');
return typeof reviver==='function'?walk({'':j},''):j;
}
throw new SyntaxError('voodooDebug.parse');
};
}
function voodooAjax() {
//////////////////////////////////////////////////////////////////////////////////
// Feather Ajax
//////////////////////////////////////////////////////////////////////////////////
// reference to the calling object
this.caller = null;
lib/Apache/Voodoo/Engine.pm view on Meta::CPAN
$self->{'mp'} = $opts{'mp'};
$self->{'constants'} = $opts{'constants'} || Apache::Voodoo::Constants->new();
$self->restart($opts{'only_start'});
# Setup signal handler for die so that all deaths become exception objects
# This way we can get a stack trace from where the death occurred, not where it was caught.
$SIG{__DIE__} = sub {
if (blessed($_[0]) && $_[0]->can("rethrow")) {
# Already died using an exception class, just pass it up the chain
$_[0]->rethrow;
}
else {
Apache::Voodoo::Exception::RunTime->throw(error => join("\n", @_));
}
};
$i_am_a_singleton = $self;
return $self;
}
sub valid_app {
my $self = shift;
lib/Apache/Voodoo/Engine.pm view on Meta::CPAN
}
sub init_app {
my $self = shift;
my $id = shift || $self->{'mp'}->get_app_id();
$self->{'app_id'} = $id;
unless (defined($id)) {
Apache::Voodoo::Exception::Application->throw(
"PerlSetVar ID not present in configuration. Giving up."
);
}
# app exists?
unless ($self->valid_app($id)) {
Apache::Voodoo::Exception::Application->throw(
"Application id '$id' unknown. Valid ids are: ".join(",",$self->get_apps())
);
}
if ($self->_app->{'dynamic_loading'}) {
$self->_app->refresh();
}
if ($self->_app->{'DEAD'}) {
Apache::Voodoo::Exception::Application->throw("Application $id failed to load.");
}
return 1;
}
sub begin_run {
my $self = shift;
$self->{'mp'}->register_cleanup($self,\&finish);
lib/Apache/Voodoo/Engine.pm view on Meta::CPAN
sub attach_db {
my $self = shift;
my $db = undef;
foreach (@{$self->_app->databases}) {
eval {
$db = DBI->connect_cached(@{$_});
};
last if $db;
Apache::Voodoo::Exception::DBIConnect->throw($DBI::errstr);
}
return $db;
}
sub parse_params {
my $self = shift;
my $params = $self->{mp}->parse_params($self->_app->config->{'upload_size_max'});
unless (ref($params)) {
Apache::Voodoo::Exception::ParamParse->throw($params);
}
$debug->mark(Time::HiRes::time,"Parameter parsing");
$debug->params($params);
return $params;
}
sub status {
my $self = shift;
my $status = shift;
lib/Apache/Voodoo/Engine.pm view on Meta::CPAN
if (!defined($session_id) || $session->id() ne $session_id) {
# This is a new session, or there was an old cookie from a previous sesion,
$self->{'mp'}->set_cookie($conf->{'cookie_name'},$session->id());
}
elsif ($session->has_expired($conf->{'session_timeout'})) {
# the session has expired
$self->{'mp'}->set_cookie($conf->{'cookie_name'},'!','now');
$session->destroy;
Apache::Voodoo::Exception::Application::SessionTimeout->throw(
target => $self->_adjust_url("/timeout"),
error => "Session has expired"
);
}
# update the session timer
$session->touch();
return $session;
}
lib/Apache/Voodoo/Engine.pm view on Meta::CPAN
$debug->mark(Time::HiRes::time,"history capture");
}
sub get_model {
my $self = shift;
my $app_id = shift;
my $model = shift;
unless ($self->valid_app($app_id)) {
Apache::Voodoo::Exception::Application->throw(
"Application id '$app_id' unknown. Valid ids are: ".join(",",$self->get_apps())
);
}
return $self->{'apps'}->{$app_id}->{'models'}->{$model};
}
sub execute_controllers {
my $self = shift;
my $uri = shift;
lib/Apache/Voodoo/Engine.pm view on Meta::CPAN
eval {
$return = $obj->$method($self->{'p'});
};
$debug->mark(Time::HiRes::time,"handler for ".$c->[0]." ".$c->[1]);
$debug->return_data($c->[0],$c->[1],$return);
if (my $e = Exception::Class->caught()) {
if (ref($e) =~ /(AccessDenied|Redirect|DisplayError)$/) {
$e->{'target'} = $self->_adjust_url($e->target);
$e->rethrow();
}
elsif (ref($e)) {
$e->rethrow();
}
else {
Apache::Voodoo::Exception::RunTime->throw("$@");
}
}
if (!defined($template_params) || !ref($return)) {
# first overwrites empty, or scalar overwrites previous
$template_params = $return;
}
elsif (ref($return) eq "HASH" && ref($template_params) eq "HASH") {
# merge two hashes
foreach my $k ( keys %{$return}) {
$template_params->{$k} = $return->{$k};
}
$debug->mark(Time::HiRes::time,"result packing");
}
elsif (ref($return) eq "ARRAY" && ref($template_params) eq "ARRAY") {
# merge two arrays
push(@{$template_params},@{$return});
}
else {
# eep. can't merge.
Apache::Voodoo::Exception::RunTime::BadReturn->throw(
module => $c->[0],
method => $c->[1],
data => $return
);
}
last if $self->{'p'}->{'_stop_chain_'};
}
}
lib/Apache/Voodoo/Engine.pm view on Meta::CPAN
defined($self->_app->{'views'}->{$self->{'p'}->{'template_conf'}->{'default_view'}})) {
$view = $self->_app->{'views'}->{$self->{'p'}->{'template_conf'}->{'default_view'}};
}
else {
$view = $self->_app->{'views'}->{'HTML'};
}
$view->begin($self->{'p'});
if (blessed($content) && $content->can('rethrow')) {
$view->exception($content);
}
else {
# pack up the params. note the presidence: module overrides template_conf
$view->params($self->{'p'}->{'template_conf'});
$view->params($content);
}
# add any params from the debugging handlers
$view->params($debug->finalize());
lib/Apache/Voodoo/Install.pm view on Meta::CPAN
}
else {
$self->debug(": ok");
}
}
else {
# not there, or not a link.
# make sure the path is valid
my $p;
my @p = split('/',$target);
pop @p; # throw away filename
foreach my $d (@p) {
$p .= '/'.$d;
unless (-e $p && -d $p) {
$pretend || mkdir ($p,0755) || $self->{ignore} || die "Can't create directory: $!";
}
}
$pretend || unlink($target); # in case it was there.
$pretend || symlink($source,$target) || $self->{ignore} || die "Can't create symlink: $!";
lib/Apache/Voodoo/Table.pm view on Meta::CPAN
eval {
$self->{valid} = Apache::Voodoo::Validate->new($conf->{'columns'});
};
if (my $e = Apache::Voodoo::Exception::RunTime::BadConfig->caught()) {
# FIXME hack! need to figure out to store the list of errors as a data structure and override the stringification operation.
my (undef,@e) = split(/\n\t/,"$e");
push(@errors,@e);
}
elsif ($@) {
ref($@)?
$@->rethrow:
Apache::Voodoo::Exception::RunTime->throw($@);
}
$self->{'column_names'} = {};
while (my ($name,$conf) = each %{$conf->{'columns'}}) {
if (defined($conf->{'multiple'})) {
push(@errors,"Column $name allows multiple values but Apache::Voodoo::Table can't handle that currently.");
}
if (defined($conf->{'unique'})) {
push(@{$self->{'unique'}},$name);
lib/Apache/Voodoo/Table.pm view on Meta::CPAN
'limit',
'sort',
'last_sort',
'desc',
@{$conf->{'list_options'}->{'persist'} || []}
]
);
}
if (@errors) {
Apache::Voodoo::Exception::RunTime::BadConfig->throw("Configuration Errors:\n\t".join("\n\t",@errors));
}
}
sub table {
my $self = shift;
if ($_[0]) {
$self->{'table'} = $_[0];
}
return $self->{'table'};
}
lib/Apache/Voodoo/Validate.pm view on Meta::CPAN
return $self;
}
sub set_valid_callback {
my $self = shift;
#my $context = shift;
my $sub_ref = shift;
#unless (defined($context)) {
# Apache::Vodooo::Exception::RunTime->throw("add_callback requires a context name as the first parameter");
#}
unless (ref($sub_ref) eq "CODE") {
Apache::Vodooo::Exception::RunTime::BadConfig->throw("add_callback requires a subroutine reference as the second paramter");
}
#push(@{$self->{'callbacks'}->{$context}},$sub_ref);
$self->{'vc'} = $sub_ref;
}
sub set_error_formatter {
my $self = shift;
my $sub_ref = shift;
lib/Apache/Voodoo/Validate.pm view on Meta::CPAN
$c->{$a}->{'seq'} ||= 0;
$c->{$b}->{'seq'} ||= 0;
$c->{$a}->{'seq'} cmp $c->{$b}->{'seq'} ||
$a cmp $b;
}
keys %{$c};
}
unless (scalar(@fields)) {
Apache::Voodoo::Exception::RunTime::BadConfig->throw("Empty Configuration.");
}
$self->{'fields'} = [];
foreach my $conf (@fields) {
my $name = $conf->{id};
unless (defined($conf->{'type'})) {
push(@errors,"missing 'type' for column $name");
next;
}
lib/Apache/Voodoo/Validate.pm view on Meta::CPAN
if (defined($e[0])) {
push(@errors,@e);
next;
}
push(@{$self->{'fields'}},$field);
}
if (@errors) {
Apache::Voodoo::Exception::RunTime::BadConfig->throw("Configuration Errors:\n\t".join("\n\t",@errors));
}
}
sub _param {
my $self = shift;
my $params = shift;
my $def = shift;
my $p = $params->{$def->{'name'}};
if (ref($p) eq "ARRAY") {
lib/Apache/Voodoo/Validate/varchar.pm view on Meta::CPAN
# request. It's localized to keep Net::DNS out of my pool.
local $_;
my $addr;
eval {
$addr = Email::Valid->address('-address' => $v,
'-mxcheck' => 1,
'-fqdn' => 1 );
};
if ($@) {
Apache::Voodoo::Exception::Runtime->throw("Email::Valid produced an exception: $@");
$e = 'BAD';
}
elsif(!defined($addr)) {
$e = 'BAD';
}
}
elsif (defined($self->{'valid'}) && $self->{'valid'} eq 'url') {
if (length($v) && _valid_url($v) == 0) {
$e = 'BAD';
}
lib/Apache/Voodoo/View.pm view on Meta::CPAN
# Called at the begining of each request
#
sub begin { }
#
# Called multiple times as each handler / controller produces data.
#
sub params { }
#
# Called whenver an exception is thrown by the handler / controller.
#
sub exception { }
#
# Whatever this method returns is passed to the browser.
#
sub output { }
#
# Called at the end of each request. Here is where any cleanup happens.
lib/Apache/Voodoo/Zombie.pm view on Meta::CPAN
=pod #####################################################################################
=head1 NAME
Apache::Voodoo::Zombie - Internal module used by Voodoo when a end user module doesn't compile.
=head1 SYNOPSIS
This module is used by Apache::Voodoo::Application as a stand in for a module that didn't compile
when either devel_mode or debug is 1 in the application's voodoo.conf. Any calls to this module simply
throw an exception describing the describing the compilation error.
This is a development tool...you shouldn't have any Zombies in your production environment :)
=cut ################################################################################
package Apache::Voodoo::Zombie;
$VERSION = "3.0200";
use strict;
use warnings;
lib/Apache/Voodoo/Zombie.pm view on Meta::CPAN
my $p = shift;
our $AUTOLOAD;
my $method = $AUTOLOAD;
$method =~ s/.*:://;
if (ref($Apache::Voodoo::Engine::debug)) {
$Apache::Voodoo::Engine::debug->error($self->{'module'},$self->{'error'});
}
Apache::Voodoo::Exception::Compilation->throw(
'module' => $self->{'module'},
'error' => $self->{'error'}
);
}
# keeps autoloader from making one
sub DESTROY {}
1;
t/Validate.t view on Meta::CPAN
($v,$e) = $B->validate({bit => ''}); ok($e->{MISSING_bit},'bad bit 1');
($v,$e) = $B->validate({bit => undef}); ok($e->{MISSING_bit},'bad bit 2');
($v,$e) = $B->validate({bit => -1}); ok($e->{MISSING_bit},'bad bit 3');
($v,$e) = $B->validate({bit => 'a'}); ok($e->{MISSING_bit},'bad bit 4');
my $E;
eval {
$E = Apache::Voodoo::Validate->new({});
};
ok(ref($@) eq "Apache::Voodoo::Exception::RunTime::BadConfig",'Empty configuration throws exception 1 ');
eval {
$E = Apache::Voodoo::Validate->new();
};
ok(ref($@) eq "Apache::Voodoo::Exception::RunTime::BadConfig",'Empty configuration throws exception 2 ');