You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(381) |
Nov
(176) |
Dec
(310) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(334) |
Feb
(96) |
Mar
(149) |
Apr
(214) |
May
(120) |
Jun
(56) |
Jul
(10) |
Aug
(273) |
Sep
(182) |
Oct
(56) |
Nov
(125) |
Dec
(22) |
2003 |
Jan
(63) |
Feb
(181) |
Mar
(498) |
Apr
(433) |
May
(39) |
Jun
(512) |
Jul
(276) |
Aug
(156) |
Sep
(101) |
Oct
(66) |
Nov
(24) |
Dec
(161) |
2004 |
Jan
(1) |
Feb
(377) |
Mar
(68) |
Apr
(26) |
May
(107) |
Jun
(333) |
Jul
(13) |
Aug
|
Sep
(76) |
Oct
(88) |
Nov
(170) |
Dec
(91) |
2005 |
Jan
(52) |
Feb
(239) |
Mar
(402) |
Apr
(15) |
May
(2) |
Jun
(1) |
Jul
(13) |
Aug
|
Sep
(71) |
Oct
(34) |
Nov
|
Dec
|
2006 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(7) |
Oct
(2) |
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Chris W. <la...@us...> - 2005-02-13 20:37:43
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9810/OpenInteract2 Added Files: ActionResolver.pm Log Message: add parent class (ActionResolver) that organizes children and provides a facade for a chain of responsibility to that resolves a URL to an OI2 action; previously this was spread over OI2::Request and OI2::Controller; now it's encapsulated in smaller, more focused classes --- NEW FILE: ActionResolver.pm --- package OpenInteract2::ActionResolver; # $Id: ActionResolver.pm,v 1.1 2005/02/13 20:37:35 lachoy Exp $ use strict; use base qw( Class::Factory ); use Log::Log4perl qw( get_logger ); use OpenInteract2::Constants qw( LOG_ACTION ); use OpenInteract2::Exception qw( oi_error ); use OpenInteract2::URL; use OpenInteract2::Util; my ( $log ); $OpenInteract2::ActionResolver::VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/); sub resolver_sort { return $a->get_order <=> $b->get_order; } sub get_all_resolvers { my ( $class ) = @_; my @all_resolver_types = $class->get_registered_types(); my @resolvers = (); foreach my $type ( @all_resolver_types ) { push @resolvers, $class->new( $type ); } return sort resolver_sort @resolvers; } sub get_action { my ( $class, $request, @other ) = @_; $log ||= get_logger( LOG_ACTION ); my ( $url ); my @resolvers = (); if ( scalar @other ) { unless ( ref $other[0] ) { $url = OpenInteract2::URL->parse_absolute_to_relative( shift @other ); } @resolvers = @other; } unless ( scalar @resolvers ) { @resolvers = $class->get_all_resolvers; } $url ||= $request->url_relative; $log->info( "Sending URL '$url' to ", scalar( @resolvers ), " ", "action resolvers" ); my ( $action ); foreach my $r ( @resolvers ) { $action = eval { $r->resolve( $request, $url ) }; if ( $@ ) { $log->warn( "Resolver ", ref( $r ), " threw an ", "exception ($@); continuing with others..." ); } last if ( $action ); } return $action; } ######################################## # SUBCLASSES sub resolve { _must_implement( 'resolve', @_ ) } sub get_order { return 5 } sub _must_implement { my ( $method, $item ) = @_; my $class = ref( $item ) || $item; oi_error "Class '$class' must implement method '$method'"; } OpenInteract2::Util->find_factory_subclasses( 'OpenInteract2::ActionResolver', @INC ); 1; __END__ =head1 NAME OpenInteract2::ActionResolver - Small classes and chain of responsibility to resolve URLs to action objects =head1 SYNOPSIS # Get all the available resolver objects my @resolvers = OpenInteract2::ActionResolver->get_all_resolvers(); # Send OI2::Request object from which we get the URL using the # default resolvers... my $action = OpenInteract2::ActionResolver->get_action( $request ); # ...or specify the URL and resolvers yourself my $action = OpenInteract2::ActionResolver->get_action( $request, $url, @resolvers ); =head1 DESCRIPTION An action resolver takes a URL and tries to create an L<OpenInteract2::Action> from it. If the resolver cannot do so it does nothing and the next one is called. Resolvers are found at runtime as long as they're under the 'OpenInteract2::ActionResolver' namespace. You can also add them manually using normal L<Class::Factory> directives: OpenInteract2::ActionResolver->register_factory_class( myresolver => 'MyApplication::Resolver::FooResolver' ); =head1 CLASS METHODS C<get_all_resolvers()> Returns a list of resolver objects -- order is important! C<get_action( $request, [ $url ], [ @resolvers ] )> Match up C<$url> to the corresponding action. If not given we ask C<$request> for its C<url_relative()> property, and if C<@resolvers> aren't given we use the result from our C<get_all_resolvers()> class method. Each of the L<OpenInteract2::ActionResolver> objects in C<@resolvers> will get called and asked if it can resolve C<$url> This will either return an L<OpenInteract2::Action> object or throw an exception. C<new( $type )> Creates a new resolver -- no parameters are passed in besides the C<$type> that each resolver uses to register itself. =head1 OBJECT METHODS B<get_order()> - subclass may implement Return a number between 1 and 10 indicating when the resolver should be run. If you do not implement this the default is '5', which will probably be fine for most implementations. B<resolve( $request, $url )> - subclass must implement Tries to find data in C<$url> to create an action. The C<$url> will B<not> contain any deployment context information. (Note that C<$url> may have come from C<$request> or may have been specified by the original caller, so don't go peeking around in C<$request> for it unless you know what you're doing.) If that particular resolver does not know what to do with the URL it should return nothing to indicate that the next resolver down the line should get executed. The object may also create side-effects along the way. For instance, one of the built-in resolvers finds a parameter 'oi_language' from C<$request> and if it exists assigns that language for the request. (Yes, this technically isn't resolving an action, but there's no real use to create B<another> set of classes that perform such a similar action.) =head1 SEE ALSO L<OpenInteract2::Controller> L<OpenInteract2::Action> =head1 COPYRIGHT Copyright (c) 2005 Chris Winters. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHORS Chris Winters E<lt>ch...@cw...E<gt> |
From: Chris W. <la...@us...> - 2005-02-13 20:36:20
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9176/OpenInteract2 Modified Files: SPOPS.pm Log Message: OIN-38: remove code related to object keys Index: SPOPS.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/SPOPS.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** SPOPS.pm 6 Jan 2005 09:03:05 -0000 1.27 --- SPOPS.pm 13 Feb 2005 20:36:11 -0000 1.28 *************** *** 16,136 **** my ( $log ); - # TODO: - # - move object key stuff to a separate class - - use constant OBJECT_KEY_TABLE => 'object_keys'; - # This is not public, look away, look away! $OpenInteract2::SPOPS::TRACKING_DISABLED = 0; ######################################## - # RULESET FACTORY BEHAVIOR - ######################################## - - # TODO: Make this optional? Are we even using object keys anymore? - - sub ruleset_factory { - my ( $class, $rs_table ) = @_; - push @{ $rs_table->{post_save_action} }, \&save_object_key; - return __PACKAGE__; - } - - - # Use the object class and ID to update the object key table - - sub save_object_key { - my ( $self, $p ) = @_; - $log ||= get_logger( LOG_SPOPS ); - - # Don't create an object key if we're explicitly told not to - return 1 if ( $self->CONFIG->{skip_object_key} || $p->{skip_object_key} ); - - $p ||= {}; - my $obj_key = $self->fetch_object_key; - unless ( $obj_key ) { - $obj_key = $self->generate_object_key; - my $id = $self->id; - my $db = CTX->datasource( CTX->lookup_system_datasource_name ); - eval { - SPOPS::SQLInterface->db_insert({ - %{ $p }, - table => OBJECT_KEY_TABLE, - field => [ qw/ object_key class object_id / ], - value => [ $obj_key, ref( $self ), $id ], - db => $db, }) - }; - if ( $@ ) { - $log->error( "Cannot save object key: $@" ); - return undef; - } - } - return $self->{tmp_object_key} = $obj_key; - } - - - ######################################## - # OBJECT KEY - - # Create a unique key based on the class and ID - - sub generate_object_key { - my ( $self ) = @_; - return md5_hex( ref( $self ) . $self->id ); - } - - - # Retrieve the object key based on the class and ID - - sub fetch_object_key { - my ( $self, $p ) = @_; - $p ||= {}; - my $id = $self->id; - my $db = CTX->datasource( CTX->lookup_system_datasource_name ); - my $row = $self->db_select({ %{ $p }, - from => OBJECT_KEY_TABLE, - select => [ 'object_key' ], - where => 'class = ? AND object_id = ?', - value => [ ref $self, scalar $id ], - return => 'single', - db => $db }); - return $row->[0] if ( $row ); - return undef; - } - - - # Retrieve the object class and ID given an object_key - - sub fetch_object_info_by_key { - my ( $class, $key, $p ) = @_; - $p ||= {}; - my $db = CTX->datasource( CTX->lookup_system_datasource_name ); - die "Cannot retrieve object info without key!" unless ( $key ); - my $row = SPOPS::SQLInterface->db_select({ - %{ $p }, - from => OBJECT_KEY_TABLE, - select => [ 'class', 'object_id' ], - where => 'object_key = ?', - value => [ $key ], - return => 'single', - db => $db }); - return ( $row->[0], $row->[1] ) if ( $row ); - return undef; - } - - - # Retrieve an object given an object_key - - sub fetch_object_by_key { - my ( $class, $key, $p ) = @_; - my ( $object_class, $object_id ) = - $class->fetch_object_info_by_key( $key, $p ); - if ( $object_class and $object_id ) { - return $object_class->fetch( $object_id, $p ); - } - return undef; - } - - - ######################################## # OBJECT TRACK METHODS --- 16,23 ---- *************** *** 508,558 **** [ uid of updater, date of update ] - =head1 OBJECT KEY METHODS - - We use a object key to uniquely identify each object in the - system. (Generally the object key is a digest formed from the class - and object ID.) - - B<generate_object_key()> - - Creates a unique key based on the class and ID. (Currently using - L<Digest::MD5>.) - - B<save_object_key( \%params )> - - Checks to see if an object key already exists for this class and ID - and if not, creates a new key and saves it to the lookup table. - - Returns: the object key retrieved or saved - - B<fetch_object_key()> - - Retreives an object key based on the class and ID of an object. - - Returns: the object key associated with the class and ID, or undef if - none found. - - B<fetch_object_info_by_key( $key, \%params )> - - Given an object key, lookup the object class and ID associated with it. - - Returns: If matching information found, a two-element list -- the - first element is the object class, the second is the object ID. If no - matching information is found, undef. matching information found, re - - B<fetch_object_by_key( $key, \%params )> - - Given an object key, fetch the object associated with it. - - Returns: If key matches class and ID in lookup table, the object with - the class and ID. If no match found, return undef. - - =head1 RULESET METHODS - - We create one rule in the ruleset of each object. In the - B<post_save_action> step we ensure that this object has an entry in - the object key table. (See description of C<save_object_key()> for - information about the implementation.) - =head1 METHODS --- 395,398 ---- |
From: Chris W. <la...@us...> - 2005-02-13 20:34:22
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/ActionResolver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8069/lib/OpenInteract2/ActionResolver Log Message: Directory /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/ActionResolver added to the repository |
From: Chris W. <la...@us...> - 2005-02-13 20:33:44
|
Update of /cvsroot/openinteract/OpenInteract2/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7846/t Modified Files: utils.pl Log Message: if the environment variable OI2DEBUG is set then assign the log4perl level to DEBUG for all tests Index: utils.pl =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/t/utils.pl,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** utils.pl 26 Jan 2005 02:36:14 -0000 1.87 --- utils.pl 13 Feb 2005 20:33:35 -0000 1.88 *************** *** 23,29 **** BEGIN { ! #my $log_level = $DEBUG; ! # TODO: Change before distributing! ! my $log_level = $WARN; $log = OpenInteract2::Log->init_file( 'oi2_tests.log', $log_level ); $log->warn( "Starting test run [$0] [", scalar localtime, "]" ); --- 23,27 ---- BEGIN { ! my $log_level = ( $ENV{OI2DEBUG} ) ? $DEBUG : $WARN; $log = OpenInteract2::Log->init_file( 'oi2_tests.log', $log_level ); $log->warn( "Starting test run [$0] [", scalar localtime, "]" ); |
From: Chris W. <la...@us...> - 2005-02-13 20:33:06
|
Update of /cvsroot/openinteract/OpenInteract2/sample/package_cpan In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7452/sample/package_cpan Modified Files: App.pm Log Message: fix pod error in generated code Index: App.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/sample/package_cpan/App.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** App.pm 8 Feb 2005 12:32:48 -0000 1.1 --- App.pm 13 Feb 2005 20:32:57 -0000 1.2 *************** *** 25,27 **** [% package_pod %] ! =back --- 25,27 ---- [% package_pod %] ! =cut |
From: Chris W. <la...@us...> - 2005-02-13 20:32:44
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Manage/Website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7315/lib/OpenInteract2/Manage/Website Modified Files: PackageCheckExportInstall.pm Log Message: cosmetic Index: PackageCheckExportInstall.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Manage/Website/PackageCheckExportInstall.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PackageCheckExportInstall.pm 13 Jun 2004 18:19:54 -0000 1.3 --- PackageCheckExportInstall.pm 13 Feb 2005 20:32:36 -0000 1.4 *************** *** 6,9 **** --- 6,10 ---- use base qw( OpenInteract2::Manage::Website ); use Cwd qw( cwd ); + use File::Spec::Functions qw( catfile ); use Log::Log4perl qw( get_logger ); use OpenInteract2::Constants qw( :log ); *************** *** 37,41 **** my ( $self, $param_name, $param_value ) = @_; if ( $param_name eq 'package_dir' ) { ! my $package_conf_file = File::Spec->catfile( $param_value, 'package.conf' ); unless ( -f $package_conf_file ) { return "Directory does not appear to be a package"; --- 38,42 ---- my ( $self, $param_name, $param_value ) = @_; if ( $param_name eq 'package_dir' ) { ! my $package_conf_file = catfile( $param_value, 'package.conf' ); unless ( -f $package_conf_file ) { return "Directory does not appear to be a package"; |
From: Chris W. <la...@us...> - 2005-02-13 20:32:28
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Manage/Website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7156/lib/OpenInteract2/Manage/Website Modified Files: InstallPackageSql.pm Log Message: modify what we skip when first creating the context Index: InstallPackageSql.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Manage/Website/InstallPackageSql.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** InstallPackageSql.pm 24 Jan 2005 17:02:38 -0000 1.12 --- InstallPackageSql.pm 13 Feb 2005 20:32:18 -0000 1.13 *************** *** 30,34 **** sub setup_task { my ( $self ) = @_; ! $self->_setup_context( { skip => 'initialize spops' } ); } --- 30,34 ---- sub setup_task { my ( $self ) = @_; ! $self->_setup_context( { skip => 'read spops config' } ); } *************** *** 45,50 **** $self->_add_status( $struct->get_status ); ! # Initializes the SPOPS objects now that the tables are created... ! OpenInteract2::Setup->run_setup_for( 'initialize spops' ); $data->execute; --- 45,51 ---- $self->_add_status( $struct->get_status ); ! # Reads and initializes the SPOPS objects now that the tables ! # are created... ! OpenInteract2::Setup->run_setup_for( 'read spops config' ); $data->execute; |
From: Chris W. <la...@us...> - 2005-02-13 20:29:19
|
Update of /cvsroot/openinteract/OpenInteract2/sample/website/conf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5643/sample/website/conf Modified Files: server.ini Log Message: clarify configuration of none/not_found actions Index: server.ini =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/sample/website/conf/server.ini,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** server.ini 28 Nov 2004 04:28:59 -0000 1.48 --- server.ini 13 Feb 2005 20:29:10 -0000 1.49 *************** *** 552,565 **** # not found (under 'action_info.not_found') [action_info default] controller = tt-template content_generator = TT - [action_info none] - redir = page - - [action_info not_found] - redir = page - [action_types] template_only = OpenInteract2::Action::TemplateOnly --- 552,563 ---- # not found (under 'action_info.not_found') + [action_info] + none = page + not_found = page + [action_info default] controller = tt-template content_generator = TT [action_types] template_only = OpenInteract2::Action::TemplateOnly |
From: Chris W. <la...@us...> - 2005-02-13 20:28:50
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5334/lib/OpenInteract2 Modified Files: Context.pm Log Message: modify how the none/not_found actions are brought in since we modified the server configuration slightly; some cosmetic error/debugging message fixes Index: Context.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Context.pm,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** Context.pm 2 Feb 2005 13:06:01 -0000 1.82 --- Context.pm 13 Feb 2005 20:28:41 -0000 1.83 *************** *** 345,351 **** unless ( $action_info ) { ! $log_act->error( "Action '$action_name' not found in action table" ); ! OpenInteract2::Exception->throw( ! "Action '$action_name' not found in action table" ); } --- 345,351 ---- unless ( $action_info ) { ! my $msg = "Action '$action_name' not found in action table" ; ! $log_act->error( $msg ); ! OpenInteract2::Exception->throw( $msg ); } *************** *** 378,424 **** my $action_info = $self->lookup_action_info( $action_name ); unless ( $action_info ) { ! $log_act->error( "No action found for '$action_name'" ); ! OpenInteract2::Exception->throw( ! "No action defined for '$action_name'" ); } return OpenInteract2::Action->new( $action_info, $props ); } - sub lookup_action_none { my ( $self ) = @_; ! $log_act ||= get_logger( LOG_ACTION ); ! my $action_info = $self->server_config->{action_info}{none}; ! unless ( $action_info ) { ! $log_act->error( "Please define the server configuration entry ", ! "under 'action_info.none'" ); ! OpenInteract2::Exception->throw( ! "The 'none' item under 'action_info' is not defined. ", ! "Please check your server configuration." ); ! } ! if ( my $action_name = $action_info->{redir} ) { ! return $self->lookup_action( $action_name ); ! } ! return OpenInteract2::Action->new( $action_info ); } - sub lookup_action_not_found { my ( $self ) = @_; ! $log_act ||= get_logger( LOG_ACTION ); ! my $action_info = $self->server_config->{action_info}{not_found}; ! unless ( $action_info ) { ! $log_act->error( "Please define the server configuration entry ", ! "under 'action_info.not_found'" ); ! OpenInteract2::Exception->throw( ! "The 'not_found' item under 'action_info' is not ", ! "defined. Please check your server configuration." ); ! } ! if ( my $action_name = $action_info->{redir} ) { ! return $self->lookup_action( $action_name ); ! } ! return OpenInteract2::Action->new( $action_info ); } sub lookup_default_action_info { --- 378,417 ---- my $action_info = $self->lookup_action_info( $action_name ); unless ( $action_info ) { ! my $msg = "No action found for '$action_name'"; ! $log_act->error( $msg ); ! OpenInteract2::Exception->throw( $msg ); } return OpenInteract2::Action->new( $action_info, $props ); } sub lookup_action_none { my ( $self ) = @_; ! my $action_name = $self->server_config->{action_info}{none}; ! return $self->_create_action_from_name( ! $action_name, 'action_info.none' ! ); } sub lookup_action_not_found { my ( $self ) = @_; ! my $action_name = $self->server_config->{action_info}{not_found}; ! return $self->_create_action_from_name( ! $action_name, 'action_info.not_found' ! ); } + sub _create_action_from_name { + my ( $self, $name, $key ) = @_; + unless ( $name ) { + my $msg = join( '', + "Check your server configuration -- you must define an ", + "action number in your server configuration under '$key'" + ); + $log_act ||= get_logger( LOG_ACTION ); + $log_act->error( $msg ); + OpenInteract2::Exception->throw( $msg ); + } + return $self->lookup_action( $name ); + } sub lookup_default_action_info { *************** *** 435,441 **** $log_spops ||= get_logger( LOG_SPOPS ); unless ( $object_name ) { ! $log_spops->error( "Must lookup object class using name" ); ! OpenInteract2::Exception->throw( ! "Cannot lookup object class without object name" ); } my $spops_config = $self->spops_config; --- 428,434 ---- $log_spops ||= get_logger( LOG_SPOPS ); unless ( $object_name ) { ! my $msg = "Cannot lookup object class without object name"; ! $log_spops->error( $msg ); ! OpenInteract2::Exception->throw( $msg ); } my $spops_config = $self->spops_config; |
From: Chris W. <la...@us...> - 2005-02-13 20:27:40
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4874/lib/OpenInteract2 Modified Files: Controller.pm Log Message: use OI2::ActionResolver framework to figure out what action to run and move some of our functionality there Index: Controller.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Controller.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Controller.pm 24 Jan 2005 16:57:55 -0000 1.24 --- Controller.pm 13 Feb 2005 20:27:31 -0000 1.25 *************** *** 4,11 **** use strict; ! use base qw( Class::Accessor::Fast Class::Factory ); use Log::Log4perl qw( get_logger ); - use OpenInteract2::Context qw( CTX ); use OpenInteract2::Constants qw( :log ); use OpenInteract2::Exception qw( oi_error ); --- 4,11 ---- use strict; ! use base qw( Class::Accessor::Fast Class::Factory Class::Observable ); use Log::Log4perl qw( get_logger ); use OpenInteract2::Constants qw( :log ); + use OpenInteract2::Context qw( CTX ); use OpenInteract2::Exception qw( oi_error ); *************** *** 17,72 **** __PACKAGE__->mk_accessors( @FIELDS ); - my ( $NONE_ACTION, $NOTFOUND_ACTION ); - - sub initialize_default_actions { - my ( $class ) = @_; - return if ( $NONE_ACTION and $NOTFOUND_ACTION ); - $NONE_ACTION = CTX->lookup_action_none; - $NOTFOUND_ACTION = CTX->lookup_action_not_found; - } - sub new { my ( $class, $request, $response ) = @_; $log ||= get_logger( LOG_ACTION ); ! my $action = $class->_find_action( $request ); my $impl_type = $action->controller; my $impl_class = $class->_get_controller_implementation_class( $impl_type ); $log->is_debug && ! $log->debug( "Controller for [Action: ", $action->name, "] ", ! "to use [Controller Type: $impl_type] ", ! "[Controller class: $impl_class]" ); my $self = bless( {}, $impl_class ); $self->type( $impl_type ); - $self->initial_action( $action ); - # This will probably remain undocumented for a bit... it would be - # nice to be able to add other observers at request-time to an - # action but I don't want to create a framework without any use - # cases... - - # Add a filter (observer) at runtime to the main action. So you - # could do: - # - # /news/display/?news_id=55&OI_FILTER=pittsburghese - # - # and have the news item be translated to da burg. You could even - # do: - # - # /news/display/?news_id=55&OI_FILTER=pittsburghese&OI_FILTER=bork - # - # and have it run through the yinzer AND the bork filter. - - my @filter_add = $request->param( 'OI_FILTER' ); - if ( scalar @filter_add ) { - foreach my $filter_name ( @filter_add ) { - CTX->map_observer( $filter_name, $action ); - } - } - - # TODO: Why not do this with the class? hmm... - my $controller_info = CTX->lookup_controller_config( $impl_type ); $self->generator_type( $controller_info->{content_generator} ); --- 17,36 ---- __PACKAGE__->mk_accessors( @FIELDS ); sub new { my ( $class, $request, $response ) = @_; $log ||= get_logger( LOG_ACTION ); ! my $action = OpenInteract2::ActionResolver->get_action( $request ); ! my $impl_type = $action->controller; my $impl_class = $class->_get_controller_implementation_class( $impl_type ); $log->is_debug && ! $log->debug( "Action '", $action->name, "' to use controller ", ! "[type: $impl_type] [class: $impl_class]" ); my $self = bless( {}, $impl_class ); $self->type( $impl_type ); $self->initial_action( $action ); my $controller_info = CTX->lookup_controller_config( $impl_type ); $self->generator_type( $controller_info->{content_generator} ); *************** *** 74,77 **** --- 38,43 ---- $self->init; + $self->notify_observers( 'action assigned', $action ); + CTX->controller( $self ); return $self; *************** *** 82,132 **** sub execute { my $class = ref( $_[0] ) || $_[0]; ! oi_error "Subclass [$class] must override execute()"; } - # Ask the request for the action and task name, then lookup the - # action. If it's defined and found use it; if it's defined and not - # found, use the $NOTFOUND_ACTION; if it's not defined use the - # $NONE_ACTION. - - sub _find_action { - my ( $class, $request ) = @_; - $log ||= get_logger( LOG_ACTION ); - - my ( $action_name, $task_name ) = - ( $request->action_name, $request->task_name ); - my ( $action ); - if ( $action_name ) { - $log->is_debug && - $log->debug( "Trying [Action: $action_name] [Task: $task_name] ", - "in controller" ); - $action = eval { - CTX->lookup_action( $action_name, - { REQUEST_URL => $request->url_initial } ) - }; - if ( $@ ) { - $log->warn( "Caught exception from Context trying to lookup ", - "action '$action_name': $@\nUsing action ", - "specified for 'notfound'" ); - $action = $NOTFOUND_ACTION->clone(); - } - else { - $action->task( $task_name ) if ( $task_name ); - } - } - else { - $log->is_debug && - $log->debug( "Using action specified for 'none': ", - "'", $NONE_ACTION->name, "'" ); - $action = $NONE_ACTION->clone(); - } - $log->is_debug && - $log->debug( 'Found action in controller ', - '[Action: ', $action->name, '] ', - '[Task: ', $action->task, ']' ); - return $action; - } - sub _get_controller_implementation_class { my ( $class, $controller_type ) = @_; --- 48,55 ---- sub execute { my $class = ref( $_[0] ) || $_[0]; ! oi_error "Subclass '$class' must override execute()"; } sub _get_controller_implementation_class { my ( $class, $controller_type ) = @_; *************** *** 176,180 **** =head1 SYNOPSIS ! # In whatever adapter you're using you'll have this: my $controller = eval { --- 99,103 ---- =head1 SYNOPSIS ! # In your adapter: my $controller = eval { *************** *** 191,216 **** =head1 DESCRIPTION ! Object that determines which action gets executed and what happens to ! its content. Typically its content gets placed into a larger template (see L<OpenInteract2::Controller::MainTemplate>), but you can perform other tasks as well. =head1 METHODS =head2 Class methods ! B<initialize_default_actions()> ! Class method called by ! L<OpenInteract2::Setup::InitializeControllers>. This finds and stores ! the actions under the 'action_info.none' and 'action_info.not_found' ! server configuration keys. These are returned by the context from the ! C<lookup_action_none()> and C<lookup_action_not_found()> methods. ! B<new( $request, $response )> ! Find the action to create from the data in C<$request>. Given the ! action, determine which controller implementation to use and ! instantiate an object of that type and return it. =head2 Object methods --- 114,146 ---- =head1 DESCRIPTION ! The controller determines from the URL or other identifier which ! action gets executed and what happens the content that action ! generates. Typically that content gets placed into a larger template (see L<OpenInteract2::Controller::MainTemplate>), but you can perform other tasks as well. + In the big picture, the controller is instantiated and invoked from + the adapter (see L<OpenInteract2::Manual::Architecture>) and is really + the gateway to the whole content generation process. + =head1 METHODS =head2 Class methods ! B<new( $request, $response )> ! Find the action to create from the data in C<$request>. We do this by ! passing the request to a series of L<OpenInteract2::ActionResolver> ! objects, each of which looks at the URL (or other information) from ! the C<$request> and decides if it should create an ! L<OpenInteract2::Action> object from it. ! Once we get the action object we ask it for its controller class, ! instantiate an object of that class and assign that controller to the ! context. ! We also notify all the controller observers (classes in ! C<OpenInteract2::Observer::Controller>) with 'action assigned' and the ! action created. =head2 Object methods |
From: Chris W. <la...@us...> - 2005-02-13 20:27:00
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Setup In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4379/lib/OpenInteract2/Setup Modified Files: RequireClasses.pm Log Message: add debugging Index: RequireClasses.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Setup/RequireClasses.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RequireClasses.pm 24 Jan 2005 17:17:31 -0000 1.1 --- RequireClasses.pm 13 Feb 2005 20:26:34 -0000 1.2 *************** *** 5,8 **** --- 5,10 ---- use strict; use base qw( OpenInteract2::Setup ); + use Log::Log4perl qw( get_logger ); + use OpenInteract2::Constants qw( LOG_INIT ); use OpenInteract2::Exception qw( oi_error ); use OpenInteract2::Util; *************** *** 16,27 **** sub execute { my ( $self ) = @_; my @to_require = $self->_find_classes_to_require; foreach my $require_class ( @to_require ) { next unless ( $require_class ); eval "require $require_class"; if ( $@ ) { - my $type = $self->param( 'classes_type' ) || 'Class'; oi_error "$type: failed to require class '$require_class': $@"; } } $self->param( required_classes => \@to_require ); --- 18,33 ---- sub execute { my ( $self ) = @_; + $log ||= get_logger( LOG_INIT ); + my $type = $self->param( 'classes_type' ) || 'Class'; my @to_require = $self->_find_classes_to_require; + $log->is_debug && + $log->debug( "$type to require: ", join( ', ', @to_require ) ); foreach my $require_class ( @to_require ) { next unless ( $require_class ); eval "require $require_class"; if ( $@ ) { oi_error "$type: failed to require class '$require_class': $@"; } + $log->is_debug && $log->debug( "$type: $require_class: require ok" ); } $self->param( required_classes => \@to_require ); |
From: Chris W. <la...@us...> - 2005-02-13 20:26:32
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Setup In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4268/lib/OpenInteract2/Setup Modified Files: InitializeSPOPS.pm Log Message: cosmetic + debugging (show the names of classes brought in) Index: InitializeSPOPS.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Setup/InitializeSPOPS.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InitializeSPOPS.pm 24 Jan 2005 17:17:31 -0000 1.1 --- InitializeSPOPS.pm 13 Feb 2005 20:26:23 -0000 1.2 *************** *** 37,47 **** push @alias_classes, $alias_class if ( $alias_class ); } ! OpenInteract2::Setup->new( 'require classes', classes => \@alias_classes, classes_type => 'SPOPS implementations' )->run(); ! $log->info( "Brought in ", scalar( @alias_classes ), " SPOPS ", ! "implementation classes (aka, 'alias classes')" ); } else { --- 37,49 ---- push @alias_classes, $alias_class if ( $alias_class ); } ! my $req = OpenInteract2::Setup->new( 'require classes', classes => \@alias_classes, classes_type => 'SPOPS implementations' )->run(); ! my $req_alias = $req->param( 'required_classes' ); ! $log->info( "Brought in ", scalar( @{ $req_alias } ), " SPOPS ", ! "implementation classes (aka, 'alias classes'): ", ! join( ', ', @{ $req_alias } ) ); } else { |
From: Chris W. <la...@us...> - 2005-02-13 20:25:55
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Setup In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3972/lib/OpenInteract2/Setup Modified Files: InitializeControllers.pm Log Message: instead of telling the controller to initialize its default actions, find all the classes in OI2::Observer::Controller and add them as observers Index: InitializeControllers.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Setup/InitializeControllers.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InitializeControllers.pm 24 Jan 2005 17:17:31 -0000 1.1 --- InitializeControllers.pm 13 Feb 2005 20:25:44 -0000 1.2 *************** *** 6,12 **** use base qw( OpenInteract2::Setup ); use Log::Log4perl qw( get_logger ); ! use OpenInteract2::Constants qw( :log ); use OpenInteract2::Controller; use OpenInteract2::Exception qw( oi_error ); my ( $log ); --- 6,13 ---- use base qw( OpenInteract2::Setup ); use Log::Log4perl qw( get_logger ); ! use OpenInteract2::Constants qw( LOG_INIT ); use OpenInteract2::Controller; use OpenInteract2::Exception qw( oi_error ); + use OpenInteract2::Util; my ( $log ); *************** *** 22,30 **** sub execute { my ( $self, $ctx ) = @_; my $controllers = $ctx->lookup_controller_config; while ( my ( $name, $info ) = each %{ $controllers } ) { OpenInteract2::Controller->register_factory_type( $name => $info->{class} ); } ! OpenInteract2::Controller->initialize_default_actions; } --- 23,38 ---- sub execute { my ( $self, $ctx ) = @_; + $log ||= get_logger( LOG_INIT ); my $controllers = $ctx->lookup_controller_config; while ( my ( $name, $info ) = each %{ $controllers } ) { OpenInteract2::Controller->register_factory_type( $name => $info->{class} ); } ! my @observers = OpenInteract2::Util->find_factory_subclasses( ! 'OpenInteract2::Observer::Controller', ! ); ! foreach my $observer ( @observers ) { ! OpenInteract2::Controller->add_observer( $observer ); ! $log->info( "Added observer '$observer' to the controller" ); ! } } *************** *** 46,51 **** =head1 DESCRIPTION ! This setup action just registers all controllers found and calls ! C<initialize_default_actions()> in L<OpenInteract2::Controller>. =head2 Setup Metadata --- 54,60 ---- =head1 DESCRIPTION ! This setup action just registers all controllers found, brings in all ! classes in the C<OpenInteract2::Observer::Controller> namespace and ! registers them as observers with L<OpenInteract2::Controller>. =head2 Setup Metadata |
From: Chris W. <la...@us...> - 2005-02-13 20:23:01
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2889/lib/OpenInteract2 Modified Files: Util.pm Log Message: assume @INC in find_factry_subclasses() unless other directories given Index: Util.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Util.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Util.pm 8 Feb 2005 01:12:35 -0000 1.19 --- Util.pm 13 Feb 2005 20:22:52 -0000 1.20 *************** *** 305,309 **** sub find_factory_subclasses { my ( $class, $factory_class, @dirs ) = @_; ! %FACTORY_FILES = (); --- 305,311 ---- sub find_factory_subclasses { my ( $class, $factory_class, @dirs ) = @_; ! unless ( @dirs ) { ! @dirs = @INC; ! } %FACTORY_FILES = (); *************** *** 337,340 **** --- 339,343 ---- # messages under '-w', irritating. + my @included = (); foreach my $factory_subclass ( sort keys %FACTORY_CLASSES ) { eval "require $factory_subclass"; *************** *** 342,346 **** --- 345,353 ---- carp "Failed to bring in library '$factory_subclass': $@"; } + else { + push @included, $factory_subclass; + } } + return @included; } *************** *** 573,585 **** =head1 FACTORY SUBCLASSES ! B<find_factory_subclasses( $factory_class, @directories )> ! Finds all subclasses of C<$factory_class> using C<@directories> as the ! list of directories from which to start. So to discover all the L<OpenInteract2::Manage> subclasses from all Perl module directories we would do: OpenInteract2::Util->find_factory_subclasses( ! 'OpenInteract2::Manage', @INC ); --- 580,593 ---- =head1 FACTORY SUBCLASSES ! B<find_factory_subclasses( $factory_class, [ @directories ] )> ! Finds and requires all subclasses of C<$factory_class> using ! C<@directories> as the list of directories from which to start. (If ! C<@directories> not given we use C<@INC>.) So to discover all the L<OpenInteract2::Manage> subclasses from all Perl module directories we would do: OpenInteract2::Util->find_factory_subclasses( ! 'OpenInteract2::Manage', ); *************** *** 591,594 **** --- 599,604 ---- ); + Returns a list of all the classes included. + =head1 TO DO |
From: Chris W. <la...@us...> - 2005-02-13 20:20:14
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1797/lib/OpenInteract2 Modified Files: Setup.pm Log Message: add OpenInteract2::ParamContainer to ISA, remove old methods and modify docs to reflect Index: Setup.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Setup.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** Setup.pm 8 Feb 2005 01:11:27 -0000 1.59 --- Setup.pm 13 Feb 2005 20:20:05 -0000 1.60 *************** *** 4,8 **** use strict; ! use base qw( Class::Factory ); use Algorithm::Dependency::Ordered; use Log::Log4perl qw( get_logger ); --- 4,8 ---- use strict; ! use base qw( Class::Factory OpenInteract2::ParamContainer ); use Algorithm::Dependency::Ordered; use Log::Log4perl qw( get_logger ); *************** *** 28,49 **** my ( $class, $setup_type, %params ) = @_; my $impl_class = $class->get_factory_class( $setup_type ); ! my $self = bless( ! { param => \%params }, $impl_class ! ); $self->init(); return $self; } - sub param { - my ( $self, $key, $value ) = @_; - unless ( $key ) { - return $self->{param}; - } - if ( defined $value ) { - $self->{param}{ $key } = $value; - } - return $self->{param}{ $key }; - } - # lifecycle to the outside world --- 28,37 ---- my ( $class, $setup_type, %params ) = @_; my $impl_class = $class->get_factory_class( $setup_type ); ! my $self = bless( {}, $impl_class ); ! $self->param_assign( \%params ); $self->init(); return $self; } # lifecycle to the outside world *************** *** 161,165 **** "with 'OpenInteract2::Context->create(...)'"; } ! my $actions = $DEP->schedule( $run_action ) || []; $log->info( "Asked to run setup for '$run_action', will execute ", "actions (including deps): ", join( ', ', @{ $actions } ) ); --- 149,154 ---- "with 'OpenInteract2::Context->create(...)'"; } ! my $actions = $DEP->dependent_on( $run_action ) || []; ! unshift @{ $actions }, $run_action; $log->info( "Asked to run setup for '$run_action', will execute ", "actions (including deps): ", join( ', ', @{ $actions } ) ); *************** *** 210,213 **** --- 199,220 ---- return \@good_items; } + + sub Algorithm::Dependency::dependent_on { + my $self = shift; + my $parent = shift; + + my $all_items = $self->schedule_all(); + my @deps = (); + + foreach my $item ( @{ $all_items } ) { + next if ( $item eq $parent ); + my $all_item_dep = $self->depends( $item ); + foreach my $item_dep ( @{ $all_item_dep } ) { + push @deps, $item if ( $item_dep eq $parent ); + } + } + return \@deps; + } + WITHOUT *************** *** 332,338 **** =head2 Common functionality ! B<new( $type, %params )> ! B<param( [ $key, [ $value ] ] )> B<run( $ctx )> --- 339,346 ---- =head2 Common functionality ! See also L<OpenInteract2::ParamContainer> for parameter manipulation ! methods. ! B<new( $type, %params )> B<run( $ctx )> |
From: Chris W. <la...@us...> - 2005-02-13 20:19:19
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1405/lib/OpenInteract2 Modified Files: ParamContainer.pm Log Message: update docs using examples removed from OI2::Action Index: ParamContainer.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/ParamContainer.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ParamContainer.pm 13 Feb 2005 20:09:50 -0000 1.1 --- ParamContainer.pm 13 Feb 2005 20:19:10 -0000 1.2 *************** *** 148,160 **** B<param_add( $key, @values )> ! Add C<@values> to C<$key> instead of overwriting the previous value. B<param_clear( $key )> ! Delete any value(s) set in C<$key>. This is the only way to clear out ! a value -- using the following will not work: $foo->param( myvar => undef ); B<param_assign( \%params )> --- 148,190 ---- B<param_add( $key, @values )> ! Adds (rather than replaces) the values C<@values> to the parameter ! C<$key>. If there is a value already set for C<$key>, or if you pass ! multiple values, it is turned into an array reference and C<@values> ! C<push>ed onto the end. If there is no value already set and you only ! pass a single value it acts like the call to C<param( $key, $value )>. ! ! This is useful for potential multivalued parameters, such as if you're ! collecting messages during a process for ultimately displaying to the ! user. For instance, say we want to collect error messages: ! ! $foo->param( error_msg => "Ooops I..." ); ! $foo->param_add( error_msg => "did it again" ); ! my $full_msg = join( ' ', $foo->param( 'error_msg' ) ); ! # $full_msg = 'Ooops I... did it again' ! ! $foo->param( error_msg => "Ooops I..." ); # Set to value ! $foo->param_add( error_msg => "did it again" ); # ...add new value to existing ! $foo->param( error_msg => 'and again' ); # ...replace the earlier values entirely ! my $full_msg = join( ' ', $foo->param( 'error_msg' ) ); ! # $full_msg = 'and again' ! ! $foo->param( error_msg => "Ooops I..." ); ! $foo->param_add( error_msg => "did it again" ); ! my $messages = $foo->param( 'error_msg' ); ! # $messages->[0] = 'Ooops I...' ! # $messages->[1] = 'did it again' ! ! Returns: Context senstive value in of C<$key> B<param_clear( $key )> ! Removes all parameter values defined by C<$key>. This is the only way ! to remove a parameter -- using the following will not work: $foo->param( myvar => undef ); + Returns: value(s) previously set for the parameter C<$key>, + non-context sensitive. + B<param_assign( \%params )> |
From: Chris W. <la...@us...> - 2005-02-13 20:18:52
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1168/lib/OpenInteract2 Modified Files: Request.pm Log Message: add OpenInteract2::ParamContainer to ISA, remove old methods and modify docs to reflect; also move URL-parsing methods to OI2::ActionResolver::NameAndTask Index: Request.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Request.pm,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Request.pm 2 Feb 2005 13:13:50 -0000 1.49 --- Request.pm 13 Feb 2005 20:18:35 -0000 1.50 *************** *** 4,8 **** use strict; ! use base qw( Class::Factory Class::Accessor::Fast ); use Log::Log4perl qw( get_logger ); use DateTime; --- 4,8 ---- use strict; ! use base qw( OpenInteract2::ParamContainer Class::Factory Class::Accessor::Fast ); use Log::Log4perl qw( get_logger ); use DateTime; *************** *** 23,33 **** # ACCESSORS ! my @FIELDS = qw( now server_name remote_host user_agent referer cookie_header language_header ! url_absolute url_relative url_initial action_name task_name session auth_user auth_group auth_is_admin auth_is_logged_in ); ! __PACKAGE__->mk_accessors( @FIELDS ); my ( $REQUEST_TYPE, $REQUEST_CLASS ); --- 23,35 ---- # ACCESSORS ! my %FIELDS = map { $_ => 1 } qw( now server_name remote_host user_agent referer cookie_header language_header ! url_absolute url_relative url_initial session auth_user auth_group auth_is_admin auth_is_logged_in ); ! __PACKAGE__->mk_accessors( keys %FIELDS ); ! ! sub get_skip_params { return %FIELDS } my ( $REQUEST_TYPE, $REQUEST_CLASS ); *************** *** 77,102 **** # PARAMETERS - sub param { - my ( $self, $name, $value ) = @_; - unless ( $name ) { - return keys %{ $self->{_param} }; - } - if ( defined $value ) { - $self->{_param}{ $name } = $value; - } - if ( ref $self->{_param}{ $name } eq 'ARRAY' ) { - return ( wantarray ) - ? @{ $self->{_param}{ $name } } - : $self->{_param}{ $name }; - } - if ( exists $self->{_param}{ $name } ) { - return ( wantarray ) - ? ( $self->{_param}{ $name } ) - : $self->{_param}{ $name }; - } - return wantarray ? () : undef; - } - - sub param_toggled { my ( $self, $name ) = @_; --- 79,82 ---- *************** *** 175,199 **** $log->debug( "Setting relative URL '$relative_url'" ); $self->url_relative( $relative_url ); - - my ( $action_url, $task ) = OpenInteract2::URL->parse( $relative_url ); - $self->url_initial( $action_url ); - my ( $action_name ); - if ( $action_url ) { - $action_name = eval { CTX->lookup_action_name( $action_url ) }; - if ( $@ ) { - my $action_nf = CTX->lookup_action_not_found(); - $action_name = $action_nf->name; - } - } - else { - my $action_none = CTX->lookup_action_none(); - $action_name = $action_none->name; - } - $action_name ||= ''; - $task ||= ''; - $self->action_name( $action_name ); - $self->task_name( $task ); - $log->is_info && - $log->info( "Pulled action info '$action_name: $task' from URL" ); return $relative_url; } --- 155,158 ---- |
From: Chris W. <la...@us...> - 2005-02-13 20:16:46
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32664/lib/OpenInteract2 Modified Files: Manage.pm Log Message: add OpenInteract2::ParamContainer to ISA, remove old methods and modify docs to reflect Index: Manage.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Manage.pm,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** Manage.pm 8 Feb 2005 01:09:13 -0000 1.45 --- Manage.pm 13 Feb 2005 20:16:36 -0000 1.46 *************** *** 4,8 **** use strict; ! use base qw( Exporter Class::Factory Class::Observable ); use Cwd qw( cwd ); use File::Spec::Functions qw( :ALL ); --- 4,8 ---- use strict; ! use base qw( Exporter OpenInteract2::ParamContainer Class::Factory Class::Observable ); use Cwd qw( cwd ); use File::Spec::Functions qw( :ALL ); *************** *** 393,411 **** # PARAMETERS - sub param { - my ( $self, $key, $value ) = @_; - return $self->{params} unless ( $key ); - if ( $value ) { - $self->{params}{ $key } = $value; - } - return $self->{params}{ $key }; - } - sub param_copy_from { my ( $self, $other_task ) = @_; ! my $other_params = $other_task->param; ! while ( my ( $name, $value ) = each %{ $other_params } ) { ! $self->param( $name, $value ); ! } return $self->param; } --- 393,399 ---- # PARAMETERS sub param_copy_from { my ( $self, $other_task ) = @_; ! $self->param_assign( $other_task->param ); return $self->param; } *************** *** 820,830 **** B<param( $key, $value )> ! If C<$key> is unspecified, returns all parameters as a hashref. ! ! If C<$value> is unspecified, returns the current value set for ! parameter C<$key>. ! ! If both C<$key> and C<$value> are specified, sets the parameter ! C<$key> to C<$value> and returns it. Example: --- 808,812 ---- B<param( $key, $value )> ! See L<OpenInteract2::ParamContainer> for details. Example: *************** *** 847,851 **** Copy all parameters from C<$other_task> into this object. ! Returns: results of C<param()> on this object. B<get_status()> --- 829,833 ---- Copy all parameters from C<$other_task> into this object. ! Returns: results of C<param()> on this object after the copy B<get_status()> |
From: Chris W. <la...@us...> - 2005-02-13 20:15:23
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32044/lib/OpenInteract2 Modified Files: Action.pm Log Message: add OpenInteract2::ParamContainer to ISA, remove old methods and modify docs to reflect Index: Action.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Action.pm,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** Action.pm 24 Jan 2005 16:54:28 -0000 1.66 --- Action.pm 13 Feb 2005 20:15:15 -0000 1.67 *************** *** 4,8 **** use strict; ! use base qw( Class::Accessor::Fast Class::Observable Class::Factory Exporter ); use Log::Log4perl qw( get_logger ); use OpenInteract2::Constants qw( :log :template ); --- 4,8 ---- use strict; ! use base qw( OpenInteract2::ParamContainer Class::Accessor::Fast Class::Observable Class::Factory Exporter ); use Log::Log4perl qw( get_logger ); use OpenInteract2::Constants qw( :log :template ); *************** *** 859,924 **** # PARAMS ! sub param_assign { ! my ( $self, $params ) = @_; ! return unless ( ref $params eq 'HASH' ); ! while ( my ( $key, $value ) = each %{ $params } ) { ! next if ( $PROPS{ $key } ); ! next unless ( defined $value ); # TODO: Set empty values? ! $self->param( $key, $value ); ! } ! return $self; ! } ! ! ! sub param { ! my ( $self, $key, $value ) = @_; ! return \%{ $self->{params} } unless ( $key ); ! if ( defined $value ) { ! $self->{params}{ $key } = $value; ! } ! if ( ref $self->{params}{ $key } eq 'ARRAY' ) { ! return ( wantarray ) ! ? @{ $self->{params}{ $key } } ! : $self->{params}{ $key }; ! } ! return ( wantarray ) ! ? ( $self->{params}{ $key } ) ! : $self->{params}{ $key }; ! } ! ! sub param_add { ! my ( $self, $key, @values ) = @_; ! return undef unless ( $key ); ! my $num_values = scalar @values; ! return $self->{params}{ $key } unless ( scalar @values ); ! if ( my $existing = $self->{params}{ $key } ) { ! my $typeof = ref( $existing ); ! if ( $typeof eq 'ARRAY' ) { ! push @{ $self->{params}{ $key } }, @values; ! } ! elsif ( ! $typeof ) { ! $self->{params}{ $key } = [ $existing, @values ]; ! } ! else { ! oi_error "Cannot add $num_values values to parameter [$key] ", ! "since the parameter is defined as a [$typeof] to ", ! "which I cannot reliably add values."; ! } ! } ! else { ! if ( $num_values == 1 ) { ! $self->{params}{ $key } = $values[0]; ! } ! else { ! $self->{params}{ $key } = [ @values ]; ! } ! } ! return $self->param( $key ); ! } ! ! sub param_clear { ! my ( $self, $key ) = @_; ! return delete $self->{params}{ $key }; ! } sub param_from_request { --- 859,863 ---- # PARAMS ! sub get_skip_params { return %PROPS } sub param_from_request { *************** *** 976,985 **** my ( $self, $param_name, $message_key, @key_args ) = @_; $log ||= get_logger( LOG_ACTION ); ! if ( $message_key and $self->param($message_key) ) { my $language_handle = CTX->request->language_handle; $log->is_debug && $log->debug( "Creating message from '$message_key' field '". $self->param($message_key) ."' with args '@key_args'\n" ); ! my $msg = $language_handle->maketext( $self->param($message_key), @key_args ); return $msg if ( $msg ); } --- 915,924 ---- my ( $self, $param_name, $message_key, @key_args ) = @_; $log ||= get_logger( LOG_ACTION ); ! if ( $message_key and $self->param( $message_key ) ) { my $language_handle = CTX->request->language_handle; $log->is_debug && $log->debug( "Creating message from '$message_key' field '". $self->param($message_key) ."' with args '@key_args'\n" ); ! my $msg = $language_handle->maketext( $self->param( $message_key ), @key_args ); return $msg if ( $msg ); } *************** *** 2217,2221 **** C<\%values> that are not action properties will be set into the action parameters, also overriding the values from the action table. (See ! C<param()> below.) =item 2. --- 2156,2160 ---- C<\%values> that are not action properties will be set into the action parameters, also overriding the values from the action table. (See ! L<OpenInteract2::ParamContainer>.) =item 2. *************** *** 2469,2472 **** --- 2408,2414 ---- =head2 Object Property and Parameter Methods + See L<OpenInteract2::ParamContainer> for discussion of the C<param()>, + C<param_add()>, C<param_clear()> and C<param_assign()> methods. + B<property_assign( \%properties )> *************** *** 2518,2584 **** See L<PROPERTIES> for the list of properties in each action. - B<param_assign( \%params )> - - Assigns all items from C<\%params> that are not valid properties to - the action as parameters. - - Currently we only set parameters for which there is a defined value in - C<\%params>. - - Returns: action object (C<$self>) - - B<param( [ $key, $value ] )> - - Get/set action parameters. This can be called in three ways: - - my $params = $action->param; # $params is hashref - my $value = $action->param( $name ); # $value is any type of scalar - $action->param( $name, $new_value ); - my ( @params ) = $action->param( $name ); # ...context senstive - - Returns: if called without arguments, returns a copy of the hashref of - parameters attached to the action (changes made to the hashref will - not affect the action); if called with one or two arguments, returns - the context-sensitve new value of the parameter C<$name>. - - B<param_add( $key, @values )> - - Adds (rather than replaces) the values C<@values> to the parameter - C<$key>. If there is a value already set for C<$key>, or if you pass - multiple values, it is turned into an array reference and C<@values> - C<push>ed onto the end. If there is no value already set and you only - pass a single value it acts like the call to C<param( $key, $value )>. - - This is useful for potentially multivalue parameters, such as the - often-used 'error_msg' and 'status_msg'. You can still access the - values with C<param()> in context: - - $action->param( error_msg => "Ooops I..." ); - $action->param_add( error_msg => "did it again" ); - my $full_msg = join( ' ', $action->param( 'error_msg' ) ); - # $full_msg = 'Ooops I... did it again' - - $action->param( error_msg => "Ooops I..." ); # Set to value - $action->param_add( error_msg => "did it again" ); # ...add new value to existing - $action->param( error_msg => 'and again' ); # ...replace the earlier values entirely - my $full_msg = join( ' ', $action->param( 'error_msg' ) ); - # $full_msg = 'and again' - - $action->param( error_msg => "Ooops I..." ); - $action->param_add( error_msg => "did it again" ); - my $messages = $action->param( 'error_msg' ); - # $messages->[0] = 'Ooops I...' - # $messages->[1] = 'did it again' - - Returns: Context senstive value in of C<$key> - - B<param_clear( $key )> - - Removes all parameter values defined by C<$key>. This is the only way - to remove a parameter. - - Returns: value(s) previously set for the parameter C<$key>, - non-context sensitive. - B<param_from_request( @param_names )> --- 2460,2463 ---- *************** *** 2593,2597 **** B<add_error( @msg )> ! Adds message (C<join>ed C<msg>) to action parameter 'error_msg'). Returns: added message --- 2472,2476 ---- B<add_error( @msg )> ! Adds message (C<join>ed C<msg>) to parameter 'error_msg'). Returns: added message *************** *** 2599,2603 **** B<add_status( @msg )> ! Adds message (C<join>ed C<msg>) to action parameter 'status_msg'). Returns: added message --- 2478,2482 ---- B<add_status( @msg )> ! Adds message (C<join>ed C<msg>) to parameter 'status_msg'). Returns: added message |
From: Chris W. <la...@us...> - 2005-02-13 20:09:58
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29776/lib/OpenInteract2 Added Files: ParamContainer.pm Log Message: add simple implementation of arbitrary parameter container (mostly just copy-and-pasted from other classes which now subclass this one) --- NEW FILE: ParamContainer.pm --- package OpenInteract2::ParamContainer; # $Id: ParamContainer.pm,v 1.1 2005/02/13 20:09:50 lachoy Exp $ use strict; use OpenInteract2::Exception qw( oi_error ); $OpenInteract2::ParamContainer::VERSION = sprintf( "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/ ); sub get_skip_params { return () } sub param { my ( $self, $key, $value ) = @_; $self->{params} ||= {}; return \%{ $self->{params} } unless ( $key ); if ( defined $value ) { $self->{params}{ $key } = $value; } if ( ref $self->{params}{ $key } eq 'ARRAY' ) { return ( wantarray ) ? @{ $self->{params}{ $key } } : $self->{params}{ $key }; } return ( wantarray ) ? ( $self->{params}{ $key } ) : $self->{params}{ $key }; } sub param_add { my ( $self, $key, @values ) = @_; return undef unless ( $key ); $self->{params} ||= {}; my $num_values = scalar @values; return $self->{params}{ $key } unless ( scalar @values ); if ( my $existing = $self->{params}{ $key } ) { my $typeof = ref( $existing ); if ( $typeof eq 'ARRAY' ) { push @{ $self->{params}{ $key } }, @values; } elsif ( ! $typeof ) { $self->{params}{ $key } = [ $existing, @values ]; } else { oi_error "Cannot add $num_values values to parameter '$key' ", "since the parameter is defined as a '$typeof' to ", "which I cannot reliably add values."; } } else { if ( $num_values == 1 ) { $self->{params}{ $key } = $values[0]; } else { $self->{params}{ $key } = [ @values ]; } } return $self->param( $key ); } sub param_clear { my ( $self, $key ) = @_; $self->{params} ||= {}; return delete $self->{params}{ $key }; } sub param_assign { my ( $self, $params ) = @_; return unless ( ref $params eq 'HASH' ); my %skip_params = $self->get_skip_params(); while ( my ( $key, $value ) = each %{ $params } ) { next if ( $skip_params{ $key } ); next unless ( defined $value ); $self->param( $key, $value ); } return $self; } 1; __END__ =head1 NAME OpenInteract2::ParamContainer - Base for classes that want to hold parameters =head1 SYNOPSIS package My::Class: use base qw( OpenInteract2::ParamContainer ); my %PROPERTIES = map { $_ => 1 } qw( foo bar baz ); sub get_skip_params { return %PROPERTIES } sub new { my ( $class, %params ) = @_; my $self = bless( {}, $class ); # assigns all values except where keys specified in 'get_skip_params()' $self->param_assign( \%params ); return $self; } # Using the object my $t = My::Class->new( foo => 42, var => 'a red car' ); print "Value for 'var': ", $t->param( 'var' ); # Show all parameters -- will only print 'var' value # since 'foo' was skipped my $params = $t->param(); while ( my ( $key, $value ) = each %{ $params } ) { print "$key = $value\n"; } # overwrite $t->param( var => 'a blue car' ); # clear (delete value and key) $t->param_clear( 'var' ); # treat 'var' as multivalued $t->param_add( 'var', 'a red car', 'with titanium radio' ); # get an arrayref back (scalar context) my $value = $t->param( 'var' ); # get an array back my @values = $t->param( 'var' ); =head1 DESCRIPTION Simple base class for assigning and returning arbitrary parameters. =head1 OBJECT METHODS B<param( [ $key ], [ $value ] )> If neither C<$key> nor C<$value> given, return all parameters as a hashref. If C<$key> given, return its value. If C<$key> has multiple values then the method will return an array in list context and an arrayref in scalar context. If C<$value> given, assign it to C<$key> (overwriting any value previously set) and return its new value. B<param_add( $key, @values )> Add C<@values> to C<$key> instead of overwriting the previous value. B<param_clear( $key )> Delete any value(s) set in C<$key>. This is the only way to clear out a value -- using the following will not work: $foo->param( myvar => undef ); B<param_assign( \%params )> Bulk assign C<\%params> to the object. If you have keys in C<\%params> you want to skip return them from C<get_skip_param()> (below). =head1 SUBCLASSING B<get_skip_params()> Subclasses may define this to return a hash of parameter names that we should skip when bulk assigning them with C<param_assign()>. The use case for this is in constructors where you can do something like: my %PROPS = map { $_ => 1 } qw ( name address ); sub get_skip_params { return %PROPS } sub new { my ( $class, %settings ) = @_; my $self = bless( {}, $class ); $self->param_assign( \%settings ); while ( my ( $key, $val ) = each %settings ) { next unless ( $PROPS{ $key } ); $self->$key( $val ); } } =head1 COPYRIGHT Copyright (c) 2005 Chris Winters. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHORS Chris Winters E<lt>ch...@cw...E<gt> |
From: Chris W. <la...@us...> - 2005-02-13 19:50:00
|
Update of /cvsroot/openinteract/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20775 Modified Files: MANIFEST Log Message: add pod tests Index: MANIFEST =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/MANIFEST,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** MANIFEST 8 Feb 2005 01:57:42 -0000 1.112 --- MANIFEST 13 Feb 2005 19:49:51 -0000 1.113 *************** *** 270,273 **** --- 270,274 ---- t/observer.t t/package.t + t/pod.t t/repository.t t/request.t |
From: Chris W. <la...@us...> - 2005-02-13 19:49:23
|
Update of /cvsroot/openinteract/OpenInteract2/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20408 Added Files: pod.t Log Message: add POD tests (skipped if Test::POD n/a) --- NEW FILE: pod.t --- # -*-perl-*- # $Id: pod.t,v 1.1 2005/02/13 19:49:14 lachoy Exp $ use strict; use Test::More; eval "use Test::Pod 1.00"; if ( $@ ) { plan skip_all => "Test::Pod 1.00 required for testing POD" ; } my @pod_dirs = qw( script blib ); all_pod_files_ok( all_pod_files( @pod_dirs ) ); |
From: Salve J. N. <sj...@us...> - 2005-02-08 17:45:42
|
Update of /cvsroot/openinteract/OpenInteract2/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15300/t Modified Files: config_package.t Log Message: Rename second use of @emails to @alt_emails, since "my @emails;" was declared twice Index: config_package.t =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/t/config_package.t,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** config_package.t 8 Feb 2005 13:30:15 -0000 1.11 --- config_package.t 8 Feb 2005 17:45:31 -0000 1.12 *************** *** 73,82 **** is( $alt_names[1], 'Bar Foo', 'Second alt result from author_names()' ); ! my @emails = $c->author_emails; ! is( scalar @emails, 2, 'Number of author emails returned' ); ! is( $emails[0], '', 'First alt result from author_emails()' ); ! is( $emails[1], 'ba...@fo...', 'Second alt result from author_emails()' ); --- 73,82 ---- is( $alt_names[1], 'Bar Foo', 'Second alt result from author_names()' ); ! my @alt_emails = $c->author_emails; ! is( scalar @alt_emails, 2, 'Number of author emails returned' ); ! is( $alt_emails[0], '', 'First alt result from author_emails()' ); ! is( $alt_emails[1], 'ba...@fo...', 'Second alt result from author_emails()' ); |
From: Chris W. <la...@us...> - 2005-02-08 16:34:30
|
Update of /cvsroot/openinteract/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21011 Modified Files: BUILDING_FROM_CVS Added Files: build_all Log Message: OIN-124: fix build docs and add 'build_all' shortcut --- NEW FILE: build_all --- cd pkg rm -f *.zip ./export_all cd .. perl build_bricks perl build_docs Index: BUILDING_FROM_CVS =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/BUILDING_FROM_CVS,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BUILDING_FROM_CVS 8 Feb 2005 12:30:51 -0000 1.5 --- BUILDING_FROM_CVS 8 Feb 2005 16:34:21 -0000 1.6 *************** *** 10,15 **** > cd /path/to/OpenInteract2-CVS ! > perl build_bricks ! > perl build_docs > perl Makefile.PL or perl Build.PL > make or ./Build --- 10,14 ---- > cd /path/to/OpenInteract2-CVS ! > ./build_all > perl Makefile.PL or perl Build.PL > make or ./Build *************** *** 30,36 **** > make install or ./Build install ! But you'll run into two problems building from CVS vs. from a ! distribution. The first is related to inlined resource files used to ! build packages and websites and the second to documentation. --- 29,61 ---- > make install or ./Build install ! But you'll run into three problems building from CVS vs. from a ! distribution. The first is related to packages, the second to inlined ! resource files used to build packages and websites and the third to ! documentation. ! ! All three of these are run by the 'build_all' shell script, but if you ! want to learn more read on. ! ! ! Problem: Packages ! --------------- ! ! When you check OpenInteract out from CVS you get all the packages ! distributed with OpenInteract in their respective directories. But ! they're not in the distribution (.zip) format that the next step ! ('build_bricks') expects. ! ! To build the packages for incorporating into the bricks (also ! necessary for testing), just run: ! ! > cd /path/to/OpenInteract-CVS/pkg ! > ./export_all ! ! This will result in a number of messages from the 'oi2_manage export_package' ! command to let you know whether there are too many or too few files in ! each package and the filename of the package written out. ! ! After running the command, you should have a number of .zip files in ! the pkg/ directory which are used in the next step. |
From: Chris W. <la...@us...> - 2005-02-08 16:33:48
|
Update of /cvsroot/openinteract/OpenInteract2/sample/package In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20556/sample/package Modified Files: Action.pm package.pod Log Message: fix misbehaving pod Index: Action.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/sample/package/Action.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Action.pm 28 Jan 2005 15:37:08 -0000 1.5 --- Action.pm 8 Feb 2005 16:33:31 -0000 1.6 *************** *** 72,91 **** 1; - - __END__ - - =head1 NAME - - OpenInteract2::Action::[% class_name %] - Handler for this package - - =head1 SYNOPSIS - - =head1 DESCRIPTION - - =head1 BUGS - - =head1 TO DO - - =head1 SEE ALSO - - =head1 AUTHORS --- 72,73 ---- Index: package.pod =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/sample/package/package.pod,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** package.pod 28 Jan 2005 15:37:09 -0000 1.6 --- package.pod 8 Feb 2005 16:33:32 -0000 1.7 *************** *** 1,2 **** --- 1,4 ---- + =pod + =head1 NAME *************** *** 30,31 **** --- 32,35 ---- Who AmI E<lt>me...@wh...E<gt> + + =cut \ No newline at end of file |