Update of /cvsroot/openinteract/OpenInteract2/extra_packages/delicious_tags/OpenInteract2/Observer
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7857/OpenInteract2/Observer
Added Files:
AddDeliciousTags.pm
Log Message:
updates for 0.02
--- NEW FILE: AddDeliciousTags.pm ---
package OpenInteract2::Observer::AddDeliciousTags;
# $Id: AddDeliciousTags.pm,v 1.1 2004/10/25 02:29:30 lachoy Exp $
use strict;
use Log::Log4perl qw( get_logger );
use OpenInteract2::Constants qw( :log );
use OpenInteract2::Context qw( CTX );
use OpenInteract2::DeliciousTaggableObject;
$OpenInteract2::Observer::AddDeliciousTags::VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);
my ( $log );
sub update {
my ( $class, $action, $observation ) = @_;
return unless ( $observation eq 'post save' );
my $action_desc = join( '', '(from action/task: ',
$action->name, '/', $action->task, ')' );
$log ||= get_logger( LOG_APP );
my $object = $action->param( 'object' ) || $action->param( 'c_object' );
unless ( $object ) {
$log->warn( "Cannot find an object to which I should attach ",
"the delicious tags $action_desc" );
return;
}
my $tag_listing = $action->param( 'tags' )
|| CTX->request->param( 'tags' );
unless ( $tag_listing ) {
$log->warn( "No delicious tags found $action_desc" );
return;
}
my @all_tags = split /\s+/, $tag_listing;
OpenInteract2::DeliciousTaggableObject::add_tags( $object, @all_tags );
}
1;
__END__
=head1 NAME
OpenInteract2::Observer::AddDeliciousTags - Add tags to an object from any action
=head1 SYNOPSIS
# Add the observation as available
# in $WEBSITE_DIR/conf/observer.ini
[observer]
delicious = OpenInteract2::Observer::AddDeliciousTags
# Mark your action 'myaction' to be observed and have the tags from
# 'tags' mapped to your object
[map]
delicious = myaction
=head1 DESCRIPTION
=over 4
=item *
Only reacts to 'post save' observations; all others are ignored.
=item *
Finds the object to which it should attach the tags in the action
parameter 'object' or 'c_object'. If an object is not found there the
observer does nothing.
=item *
Finds the tags to attach in the action parameter 'tags' or the
L<OpenInteract2::Request> parameter 'tags'. If no tags are found the
observer does nothing.
=item *
On finding everything we pass the data to the C<add_tags> method of
L<OpenInteract2::DeliciousTaggableObject>.
=back
=head1 SEE ALSO
L<Class::Observable>
L<OpenInteract2::Action>
L<OpenInteract2::DeliciousTag>
=head1 COPYRIGHT
Copyright (c) 2004 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>
|