For information about current developments and future releases, see:
http://maypole.perl.org/?TheRoadmap
-2.0X XXX
+2.07 Sun Jan 16 18:45:00 2005
+ Internal changes:
+ - Removed Maypole::Model->description. It didn't work as expected and
+ clashed with 'description' columns in the database
+
Fixes:
- Model->process() shouldn't set $r->objects() to a list with a single,
undefined element
+ - Fixed overriding $r->template_args->{classmetadata} in M::V::Base
+ (Thanks to Dave Howorth for spotting the mistake)
+ - #9473: Maypole::Model::CDBI->related_class (Thanks David Baird)
+ - #9434: M::M::CDBI->search generated "uninitialized value" warnings
+
+ Templates:
+ - The addnew template will attempt to prefill form fields with request
+ parameters
+ - edit template includes 'addnew' if there is no object to edit
2.06 Wed Dec 29 01:30:00 2004
Fixes:
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Maypole
-version: 2.06
+version: 2.07
version_from: lib/Maypole.pm
installdirs: site
requires:
package Apache::MVC;
-our $VERSION = '2.06';
+our $VERSION = '2.07';
use strict;
use warnings;
use CGI::Simple;
use Maypole::Headers;
-our $VERSION = '2.06';
+our $VERSION = '2.07';
sub run {
my $self = shift;
use Maypole::Constants;
use Maypole::Headers;
-our $VERSION = '2.06';
+our $VERSION = '2.07';
__PACKAGE__->mk_classdata($_) for qw( config init_done view_object );
__PACKAGE__->mk_accessors(
sub parse_path {
my $self = shift;
$self->{path} ||= "frontpage";
- my @pi = split /\//, $self->{path};
- shift @pi while @pi and !$pi[0];
+ my @pi = $self->{path} =~ m{([^/]+)/?}g;
$self->{table} = shift @pi;
$self->{action} = shift @pi;
$self->{action} ||= "index";
use Maypole::Config;
our @ISA;
-our $VERSION = '2.06';
+our $VERSION = '2.07';
sub import {
my ( $self, @plugins ) = @_;
should be a C<HTML::Element> object containing a drop-down list of
beer styles.
-TODO =item C<description>
-TODO
-TODO This is the human-readable description provided by a class.
-
=item C<related_accessors>
This is a list of accessors which can be called on an object to get
} $class->columns;
}
-=head2 description
-
-A description of the class to be passed to the template.
-
-=cut
-
-sub description { "A poorly defined class" }
-
=head2 is_public
should return true if a certain action is supported, or false otherwise.
sub related_class {
my ( $self, $r, $accessor ) = @_;
- my $related = $self->related->{$accessor};
- if ( my $mapping = $related->{args}->{mapping} ) {
+
+ my $related = $self->meta_info( has_many => $accessor ) ||
+ $self->meta_info( has_a => $accessor ) ||
+ return;
+
+ my $mapping = $related->{args}->{mapping};
+ if ( @$mapping ) {
return $related->{foreign_class}->meta_info('has_a')->{ $$mapping[0] }
->{foreign_class};
}
$r->{template_args}{cgi_params} = $r->{params};
$r->{template_args}{errors} = \%errors;
- if ($creating) {
- undef $obj;
- $r->template("addnew");
- } else {
- $r->template("edit");
- }
+ undef $obj if $creating;
+ $r->template("edit");
}
else {
$r->{template} = "view";
my $oper = "like"; # For now
my %params = %{ $r->{params} };
my %values = map { $_ => { $oper, $params{$_} } }
- grep { length ($params{$_}) and $fields{$_} } keys %params;
+ grep { defined $params{$_} && length ($params{$_}) && $fields{$_} }
+ keys %params;
$r->template("list");
if ( !%values ) { return $self->list($r) }
# ...
);
if ($class) {
- my $classmeta = $args{classmetadata} ||= {};
+ my $classmeta = $r->template_args->{classmetadata} ||= {};
$classmeta->{name} ||= $class;
- $classmeta->{description} ||= $class->description;
$classmeta->{table} ||= $class->table;
$classmeta->{columns} ||= [ $class->display_columns ];
$classmeta->{list_columns} ||= [ $class->list_columns ];
}
# Overrides
- local $r->{template_args} = $r->{template_args};
- delete $r->{template_args}{classmetadata}; # already overrides
- %args = ( %args, %{ $r->{template_args} || {} } );
+ %args = ( %args, %{ $r->template_args || {} } );
%args;
}
[% FOR col = classmetadata.columns %]
[% NEXT IF col == "id" %]
<label><span class="field">[% classmetadata.colnames.$col %]</span>
- [% classmetadata.cgi.$col.as_XML; %]
+ [%
+ SET elem = classmetadata.cgi.$col.clone;
+ IF elem.tag == "textarea";
+ elem = elem.push_content(request.param(col));
+ ELSE;
+ elem.attr("value", request.param(col));
+ END;
+ elem.as_XML; %]
</label>
+ [% IF errors.$col %]
+ <span class="error">[% errors.$col %]</span>
+ [% END %]
+
[% END; %]
<input type="submit" name="create" value="create"/>
</fieldset>
=head1 edit
This is the edit page. It edits the passed-in object, by displaying a
-form similar to L<add_new> but with the current values filled in.
+form similar to L<addnew> but with the current values filled in.
=cut
[% PROCESS macros %]
[% INCLUDE header %]
[% INCLUDE title %]
+[% IF objects.length %]
<div id="title">Edit a [% classmetadata.moniker %]</div>
[% FOR item = objects; %]
<form action="[% base %]/[% item.table %]/do_edit/[% item.id %]" method="post">
"</fieldset></form>";
END %]
-
+[% ELSE %]
+[% INCLUDE addnew %]
+[% END %]
[% INCLUDE footer %]