[Bast-commits] r4040 - in trunk/DBIx-Class-HTMLWidget: .
lib/DBIx/Class
omega at dev.catalyst.perl.org
omega at dev.catalyst.perl.org
Fri Feb 8 08:27:11 GMT 2008
Author: omega
Date: 2008-02-08 08:27:11 +0000 (Fri, 08 Feb 2008)
New Revision: 4040
Modified:
trunk/DBIx-Class-HTMLWidget/Changes
trunk/DBIx-Class-HTMLWidget/Makefile.PL
trunk/DBIx-Class-HTMLWidget/lib/DBIx/Class/HTMLWidget.pm
Log:
Deprecate populate_from_widget, add update_with_widget and populate_with_widget instead. Attempt to fix a problem with checkboxes (#31424)
Modified: trunk/DBIx-Class-HTMLWidget/Changes
===================================================================
--- trunk/DBIx-Class-HTMLWidget/Changes 2008-02-07 11:29:23 UTC (rev 4039)
+++ trunk/DBIx-Class-HTMLWidget/Changes 2008-02-08 08:27:11 UTC (rev 4040)
@@ -1,4 +1,17 @@
Revision history for DBIx-Class-HTMLWidget
+0.20 2008-02-08
+ - DEPRECATION: populate_from_widget is marked as deprecated, and is being replaced
+ by update_with_widget.
+ - refactor the object-updating out into populate_with_widget for usecases where you
+ do not want the change to automaticly end up in the database.
+ - #31424: Attempt to fix a problem with checkboxes and values
+
+0.16 2008-02-06
+ - Fix manifest
+
+0.15 2008-02-05
+ - Note to self: COPYFILE_DISABLE=1
+
0.14 2008-02-05
- Missing dep
Modified: trunk/DBIx-Class-HTMLWidget/Makefile.PL
===================================================================
--- trunk/DBIx-Class-HTMLWidget/Makefile.PL 2008-02-07 11:29:23 UTC (rev 4039)
+++ trunk/DBIx-Class-HTMLWidget/Makefile.PL 2008-02-08 08:27:11 UTC (rev 4040)
@@ -1,10 +1,10 @@
-use ExtUtils::MakeMaker;
+use inc::Module::Install;
-WriteMakefile(
- 'NAME' => 'DBIx::Class::HTMLWidget',
- 'VERSION_FROM' => 'lib/DBIx/Class/HTMLWidget.pm',
- 'PREREQ_PM' => {
- HTML::Widget => '1.10',
- DBIx::Class => 0.05,
- },
-);
+name 'DBIx-Class-HTMLWidget';
+all_from 'lib/DBIx/Class/HTMLWidget.pm';
+
+requires 'DBIx::Class';
+requires 'HTML::Widget' => '1.10';
+
+auto_install;
+WriteAll;
Modified: trunk/DBIx-Class-HTMLWidget/lib/DBIx/Class/HTMLWidget.pm
===================================================================
--- trunk/DBIx-Class-HTMLWidget/lib/DBIx/Class/HTMLWidget.pm 2008-02-07 11:29:23 UTC (rev 4039)
+++ trunk/DBIx-Class-HTMLWidget/lib/DBIx/Class/HTMLWidget.pm 2008-02-08 08:27:11 UTC (rev 4040)
@@ -4,7 +4,7 @@
use Carp;
#use Data::Dump qw(dump);
-our $VERSION = '0.14';
+our $VERSION = '0.20';
# pod after __END__
sub fill_widget {
@@ -17,10 +17,11 @@
foreach my $element ( @real_elements ) {
my $name=$element->name;
next unless $name && $dbic->can($name) && $element->can('value');
- next if ($element->value());
if($element->isa('HTML::Widget::Element::Checkbox')) {
$element->checked($dbic->$name?1:0);
} else {
+ next if ($element->value());
+
if (ref $dbic->$name and $dbic->$name->can('id') and $dbic->$name->id) {
$element->value($dbic->$name->id);
} else {
@@ -31,10 +32,9 @@
}
}
-
-sub populate_from_widget {
+sub populate_with_widget {
my ($dbic,$result)=@_;
- croak('populate_from_widget needs a HTML::Widget::Result object as argument')
+ croak('populate_object needs a HTML::Widget::Result object as argument')
unless ref $result && $result->isa('HTML::Widget::Result');
# find all checkboxes
@@ -64,11 +64,24 @@
$dbic->$col($value)
if defined $value || exists $cb{$col};
}
- $dbic->insert_or_update;
- return $dbic;
+ return $dbic;
}
+sub update_with_widget {
+ my $self = shift;
+
+ $self = $self->populate_object(@_);
+ $self->insert_or_update;
+ return $self;
+
+}
+sub populate_from_widget {
+ my $self = shift;
+ $self = $self->update_with_widget(@_);
+ return $self;
+}
+
sub experimental_populate_from_widget {
my ($dbic,$result)=@_;
foreach (@{$result->{_elements}} ) {
@@ -170,8 +183,26 @@
Fill the values of a widgets elements with the values of the DBIC object.
+=head3 populate_with_widget $HTML::Widget::Result
+
+This method updates $self with the values from the widget. It does NOT
+update the database, only the object and basicly makes it a dirty object.
+
+=head3 update_with_widget $HTML::Widget::Result
+
+This method calls populate_with_widget and then calls insert_or_update.
+This method replaces populate_from_widget in functionality
+
+=head2 Deprecated
+
+=head3 experimental_populate_from_widget
+
+Some experiment someone did, no idea who, what or where. No whos on first
+
=head3 populate_from_widget
+This method is now deprecated in favour of update_with_widget($result);
+
my $obj=$schema->resultset('pet)->new->populate_from_widget($result);
my $item->populate_from_widget($result);
@@ -190,14 +221,14 @@
=head1 AUTHORS
-Thomas Klausner, <domm at cpan.org>, http://domm.zsi.at
-
Marcus Ramberg, <mramberg at cpan.org>
Andreas Marienborg, <omega at palle.net>
=head1 CONTRIBUTORS
+Thomas Klausner, <domm at cpan.org>, http://domm.zsi.at
+
Simon Elliott, <cpan at browsing.co.uk>
Ashley Berlin
@@ -206,14 +237,6 @@
=head1 LICENSE
-This code is Copyright (c) 2003-2006 Thomas Klausner.
-All rights reserved.
+This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
-You may use and distribute this module according to the same terms
-that Perl is distributed under.
-
-=cut
-
-
-
-
+=cut
\ No newline at end of file
More information about the Bast-commits
mailing list