r17740 - in /branches/upstream/libclass-dbi-fromform-perl: ./ current/ current/Changes current/FromForm.pm current/MANIFEST current/META.yml current/Makefile.PL current/README current/test.pl
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Mon Mar 17 11:48:20 UTC 2008
Author: eloy
Date: Mon Mar 17 11:48:18 2008
New Revision: 17740
URL: http://svn.debian.org/wsvn/?sc=1&rev=17740
Log:
[svn-inject] Installing original source of libclass-dbi-fromform-perl
Added:
branches/upstream/libclass-dbi-fromform-perl/
branches/upstream/libclass-dbi-fromform-perl/current/
branches/upstream/libclass-dbi-fromform-perl/current/Changes
branches/upstream/libclass-dbi-fromform-perl/current/FromForm.pm
branches/upstream/libclass-dbi-fromform-perl/current/MANIFEST
branches/upstream/libclass-dbi-fromform-perl/current/META.yml
branches/upstream/libclass-dbi-fromform-perl/current/Makefile.PL
branches/upstream/libclass-dbi-fromform-perl/current/README
branches/upstream/libclass-dbi-fromform-perl/current/test.pl
Added: branches/upstream/libclass-dbi-fromform-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libclass-dbi-fromform-perl/current/Changes?rev=17740&op=file
==============================================================================
--- branches/upstream/libclass-dbi-fromform-perl/current/Changes (added)
+++ branches/upstream/libclass-dbi-fromform-perl/current/Changes Mon Mar 17 11:48:18 2008
@@ -1,0 +1,14 @@
+Revision history for Perl extension Class::DBI::FromForm
+
+0.04 Fri Mar 03 09:23:00
+ - Add support for HTML::Widget
+ - Added a fill_widget for HTML::Widget
+
+0.03 Mon May 09 08:00:00 2005
+ - allow undef (Andy Grundman)
+
+0.02 Mon Mar 21 08:00:00 2005
+ - allow 0 values (adtim at mail.ru)
+
+0.01 Thu Jan 04 00:00:00 2005
+ - initial release
Added: branches/upstream/libclass-dbi-fromform-perl/current/FromForm.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libclass-dbi-fromform-perl/current/FromForm.pm?rev=17740&op=file
==============================================================================
--- branches/upstream/libclass-dbi-fromform-perl/current/FromForm.pm (added)
+++ branches/upstream/libclass-dbi-fromform-perl/current/FromForm.pm Mon Mar 17 11:48:18 2008
@@ -1,0 +1,125 @@
+package Class::DBI::FromForm;
+
+use strict;
+use vars qw/$VERSION @EXPORT/;
+use base 'Exporter';
+
+$VERSION = 0.04;
+
+ at EXPORT = qw/update_from_form create_from_form/;
+
+=head1 NAME
+
+Class::DBI::FromForm - Update Class::DBI data using Data::FormValidator or HTML Widget
+
+=head1 SYNOPSIS
+
+ package Film;
+ use Class::DBI::FromForm;
+ use base 'Class::DBI';
+
+ my $results = Data::FormValidator->check( ... );
+ my $film = Film->retrieve('Fahrenheit 911');
+ $film->update_from_form($results);
+
+ my $new_film = Film->create_from_form($results);
+
+=head1 DESCRIPTION
+
+Create and update L<Class::DBI> objects from L<Data::FormValidator> or L<HTML::Widget>.
+
+=head2 METHODS
+
+=head3 create_from_form
+
+Create a new object.
+
+=cut
+
+sub create_from_form {
+ my $class = shift;
+ die "create_from_form can only be called as a class method" if ref $class;
+ __PACKAGE__->_run_create( $class, @_ );
+}
+
+=head3 update_from_form
+
+Update object.
+
+=cut
+
+sub update_from_form {
+ my $self = shift;
+ die "update_from_form cannot be called as a class method" unless ref $self;
+ __PACKAGE__->_run_update( $self, @_ );
+}
+
+sub _run_create {
+ my ( $me, $class, $results ) = @_;
+
+ my $them = bless {}, $class;
+ my $cols = {};
+ foreach my $col ( $them->columns('All') ) {
+ if($results->isa('HTML::Widget::Result')) {
+ $cols->{$col} = $results->param($col);
+ } else {
+ $cols->{$col} = $results->valid($col);
+ }
+ }
+ return $class->create($cols);
+}
+
+sub _run_update {
+ my ( $me, $them, $results ) = @_;
+ my @cols = ( $results->isa('HTML::Widget::Result') ?
+ $results->valid :
+ keys %{ $results->valid } );
+
+ foreach my $col ( @cols ) {
+ if ( $them->can($col) ) {
+ next if $col eq $them->primary_column;
+ if($results->isa('HTML::Widget::Result')) {
+ $them->$col( $results->param($col));
+ } else {
+ $them->$col( $results->valid($col));
+ }
+ }
+ }
+ $them->update;
+ return 1;
+}
+
+
+=head1 fill_widget <widget>
+
+This only applies to L<HTML::Widget>>.
+Fills the form from a CDBI object.
+
+=cut
+
+sub fill_widget {
+ my ($me ,$widget)=@_;
+
+ foreach my $element ( @{ $widget->{_elements} } ) {
+ my $name=$element->name;
+ next unless $name && $me->can($name);
+ $element->value($me->$name);
+ }
+}
+
+=head1 SEE ALSO
+
+L<Class::DBI>, L<Class::DBI::FromCGI>, L<Data::FormValidator>
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+
+=head1 LICENSE
+
+This library is free software . You can redistribute it and/or modify it under
+the same terms as perl itself.
+
+=cut
+
+1;
Added: branches/upstream/libclass-dbi-fromform-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libclass-dbi-fromform-perl/current/MANIFEST?rev=17740&op=file
==============================================================================
--- branches/upstream/libclass-dbi-fromform-perl/current/MANIFEST (added)
+++ branches/upstream/libclass-dbi-fromform-perl/current/MANIFEST Mon Mar 17 11:48:18 2008
@@ -1,0 +1,7 @@
+Changes
+FromForm.pm
+Makefile.PL
+MANIFEST This list of files
+README
+test.pl
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libclass-dbi-fromform-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libclass-dbi-fromform-perl/current/META.yml?rev=17740&op=file
==============================================================================
--- branches/upstream/libclass-dbi-fromform-perl/current/META.yml (added)
+++ branches/upstream/libclass-dbi-fromform-perl/current/META.yml Mon Mar 17 11:48:18 2008
@@ -1,0 +1,12 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Class-DBI-FromForm
+version: 0.04
+version_from: FromForm.pm
+installdirs: site
+requires:
+ Class::DBI: 0
+ Data::FormValidator: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
Added: branches/upstream/libclass-dbi-fromform-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libclass-dbi-fromform-perl/current/Makefile.PL?rev=17740&op=file
==============================================================================
--- branches/upstream/libclass-dbi-fromform-perl/current/Makefile.PL (added)
+++ branches/upstream/libclass-dbi-fromform-perl/current/Makefile.PL Mon Mar 17 11:48:18 2008
@@ -1,0 +1,10 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ 'NAME' => 'Class::DBI::FromForm',
+ 'VERSION_FROM' => 'FromForm.pm',
+ 'PREREQ_PM' => {
+ Class::DBI => 0,
+ Data::FormValidator => 0
+ },
+);
Added: branches/upstream/libclass-dbi-fromform-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libclass-dbi-fromform-perl/current/README?rev=17740&op=file
==============================================================================
--- branches/upstream/libclass-dbi-fromform-perl/current/README (added)
+++ branches/upstream/libclass-dbi-fromform-perl/current/README Mon Mar 17 11:48:18 2008
@@ -1,0 +1,34 @@
+NAME
+ Class::DBI::FromForm - Update Class::DBI data using Data::FormValidator
+
+SYNOPSIS
+ package Film;
+ use Class::DBI::FromForm;
+ use base 'Class::DBI';
+
+ my $results = Data::FormValidator->check( ... );
+ my $film = Film->retrieve('Fahrenheit 911');
+ $film->update_from_form($results);
+
+ my $new_film = Film->create_from_form($results);
+
+DESCRIPTION
+ Create and update Class::DBI objects from Data::FormValidator.
+
+ METHODS
+ create_from_form
+ Create a new object.
+
+ update_from_form
+ Update object.
+
+SEE ALSO
+ Class::DBI, Class::DBI::FromCGI, Data::FormValidator
+
+AUTHOR
+ Sebastian Riedel, "sri at oook.de"
+
+LICENSE
+ This library is free software . You can redistribute it and/or modify it
+ under the same terms as perl itself.
+
Added: branches/upstream/libclass-dbi-fromform-perl/current/test.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libclass-dbi-fromform-perl/current/test.pl?rev=17740&op=file
==============================================================================
--- branches/upstream/libclass-dbi-fromform-perl/current/test.pl (added)
+++ branches/upstream/libclass-dbi-fromform-perl/current/test.pl Mon Mar 17 11:48:18 2008
@@ -1,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Class::DBI::FromForm' }
More information about the Pkg-perl-cvs-commits
mailing list