Apache-Wyrd

 view release on metacpan or  search on metacpan

Wyrd.pm  view on Meta::CPAN

=head1 AUTHOR

Barry King E<lt>wyrd@nospam.wyrdwright.comE<gt>

=head1 SEE ALSO

A few modules provide some of the basic services of the Library.  They
often have, and list in their SEE ALSO sections, the modules which
support them.

=over

=item Apache::Wyrd::Handler, Apache::Wyrd::DBL

For information on setting up the Apache::Wyrd abstract classes

=item Apache::Wyrd::Form

For information on smart form processing

=item Apache::Wyrd::Services::Auth

For information on the built-in authorization system

=item Apache::Wyrd::Services::Index

For information on the reverse-key indexing engine

=item Apache::Wyrd::Services::Debug

For information on the debugging sub-system

=item Apache::Wyrd::Services::SAK

The "swiss army knife" of useful methods/subroutines which are collected in one
library to improve standardization of behaviors.

=item Apache::Wyrd::Site

A collection of inter-related Wyrds which can be used to quickly implement
an integrated site with self-maintaining navigation, search engine, subject
cross-references, publication management, and dynamic state-tracked
elements.

=back

=head1 LICENSE

Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.

You should have received a copy of the GNU General Public License along
with Apache::Wyrd (see LICENSE); if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

=cut

sub _init{
	my ($dbl, $init) = @_;
	#NOTE: Because DBL is tested here for DBL compatibility, it does not need to be tested again anywhere else
	#in a Wyrd.  If it is defined, it is a DBL.
	my $not_hash = (ref($init) ne 'HASH');
	if (ref($dbl) and UNIVERSAL::can($dbl, 'verify_dbl_compatibility')) {
		$_dbl = $dbl;
		$dbl->log_bug("ERROR: Invalid data (non-hashref) apparently given to object as Initial Value -- Ignoring")
			if ($not_hash);
	}
	$init = {} if ($not_hash);
	foreach my $level (values %_loglevel) {
		$_error_handler{$level} = $_disabled_error_handler;
	}
	#must test for existence, since a loglevel can be 0 and, therefore, false
	$init->{'loglevel'} = ($dbl->loglevel || 1) unless (exists($init->{'loglevel'}));
	$init->{'loglevel'} = ($_loglevel{$init->{'loglevel'}} || $init->{'loglevel'} || 0);
	for (my $level=0; $init->{'loglevel'} >= $level; $level++) {
		$_error_handler{$level} = $_enabled_error_handler;
	}
	#set the dielevel (level lower than which, execution will terminate.  The _raise_exception() method will
	#always terminate.
	$init->{'dielevel'} = ($_loglevel{$init->{'dielevel'}} || $init->{'dielevel'} || 0);
	for (my $level=0; $init->{'dielevel'} >= $level; $level++) {
		$_error_handler{$level} = $_fatal_error_handler;
	}
	$init->{'_flags'}=Apache::Wyrd::Services::Tree->new unless ($init->{'_flags'});
	return $init;
}

#Called by output, the start of the recursive chain which interprets embedded
#Apache::Wyrd, calling their output methods in returning
sub _process_self {
	my ($self) = @_;
	my $depth = ($self->{'_depth'} || 10);
	my ($test, $temp) = (1, undef);
	my $class = $self->base_class;
	#warn "base class is $class";
	do {
		#Replace each tag with its spawned contents
		#$1 = whole Object
		#$2 = class
		#$4/$5 = params
		#$6 = Enclosed Data
		$temp = $self->{'_data'};
		$test = ($temp =~
				s[
					(						#$1
						<					#tag beginning
							$class
							::
							(				#$2 v
								[:\w]+		#class
							)
						(					#$3
							(				#$4 v
								[^>]*		#params and
							)
							\s/>			#endpoint
						|					#or
							(				#5 v
								[^>]*		#params and
							)
							>				#closure plus...
								(			#$6 v
									.*?		#data
								)
							</
								$class
								::
								\2			#matched class



( run in 0.699 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )