[Jifty-commit] r4854 - in jifty/trunk: lib/Jifty
lib/Jifty/View/Declare lib/Jifty/Web
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Jan 15 15:55:14 EST 2008
Author: alexmv
Date: Tue Jan 15 15:55:13 2008
New Revision: 4854
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/View/Declare/CRUD.pm
jifty/trunk/lib/Jifty/Web.pm
jifty/trunk/lib/Jifty/Web/Form.pm
Log:
r26783 at zoq-fot-pik: chmrr | 2008-01-15 15:53:05 -0500
* Don't explicitly register the delete action in CRUD
* Check that forms that are opened are closed
* Perltidy to fix indentation in Jifty::Web
Modified: jifty/trunk/lib/Jifty/View/Declare/CRUD.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Declare/CRUD.pm (original)
+++ jifty/trunk/lib/Jifty/View/Declare/CRUD.pm Tue Jan 15 15:55:13 2008
@@ -418,8 +418,6 @@
my $delete = $record->as_delete_action(
moniker => 'delete-' . Jifty->web->serial,
);
- Jifty->web->form->register_action($delete);
-
div {
{ class is 'crud editlink' };
hyperlink(
@@ -438,13 +436,13 @@
args => { object_type => $object_type, id => $id }
},
as_button => 1,
- class => 'cancel'
+ class => 'cancel'
);
if ( $record->current_user_can('delete') ) {
$delete->button(
label => _('Delete'),
onclick => {
- submit => $delete,
+ submit => $delete,
confirm => _('Really delete?'),
refresh => Jifty->web->current_region->parent,
},
Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm (original)
+++ jifty/trunk/lib/Jifty/Web.pm Tue Jan 15 15:55:13 2008
@@ -385,57 +385,57 @@
}
sub _process_valid_actions {
- my $self = shift;
+ my $self = shift;
my $valid_actions = shift;
- for my $request_action (@$valid_actions) {
+ for my $request_action (@$valid_actions) {
- # Pull the action out of the request (again, since
- # mappings may have affected parameters). This
- # returns the cached version unless the request has
- # been changed by argument mapping from previous
- # actions (Jifty::Request::Mapper)
- my $action = $self->new_action_from_request($request_action);
- next unless $action;
- if ( $request_action->modified ) {
-
- # If the request's action was changed, re-validate
- $action->result( Jifty::Result->new );
- $action->result->action_class( ref $action );
- $self->response->result(
- $action->moniker => $action->result );
- $self->log->debug( "Re-validating action "
- . ref($action) . " "
- . $action->moniker );
- next unless $action->validate;
- }
-
- $self->log->debug(
- "Running action " . ref($action) . " " . $action->moniker );
- eval { $action->run; };
- $request_action->has_run(1);
-
- if ( my $err = $@ ) {
-
- # Poor man's exception propagation; we need to get
- # "LAST RULE" and "ABORT" exceptions back up to the
- # dispatcher. This is specifically for redirects from
- # actions
- die $err if ( $err =~ /^(LAST RULE|ABORT)/ );
- $self->log->fatal($err);
- $action->result->error(
- Jifty->config->framework("DevelMode")
- ? $err
- : _("There was an error completing the request. Please try again later."
- )
- );
- }
-
- # Fill in the request with any results that that action
- # may have yielded.
- $self->request->do_mapping;
+ # Pull the action out of the request (again, since
+ # mappings may have affected parameters). This
+ # returns the cached version unless the request has
+ # been changed by argument mapping from previous
+ # actions (Jifty::Request::Mapper)
+ my $action = $self->new_action_from_request($request_action);
+ next unless $action;
+ if ( $request_action->modified ) {
+
+ # If the request's action was changed, re-validate
+ $action->result( Jifty::Result->new );
+ $action->result->action_class( ref $action );
+ $self->response->result( $action->moniker => $action->result );
+ $self->log->debug( "Re-validating action "
+ . ref($action) . " "
+ . $action->moniker );
+ next unless $action->validate;
}
+ $self->log->debug(
+ "Running action " . ref($action) . " " . $action->moniker );
+ eval { $action->run; };
+ $request_action->has_run(1);
+
+ if ( my $err = $@ ) {
+
+ # Poor man's exception propagation; we need to get
+ # "LAST RULE" and "ABORT" exceptions back up to the
+ # dispatcher. This is specifically for redirects from
+ # actions
+ die $err if ( $err =~ /^(LAST RULE|ABORT)/ );
+ $self->log->fatal($err);
+ $action->result->error(
+ Jifty->config->framework("DevelMode")
+ ? $err
+ : _("There was an error completing the request. Please try again later."
+ )
+ );
+ }
+
+ # Fill in the request with any results that that action
+ # may have yielded.
+ $self->request->do_mapping;
}
+
+}
+
=head3 request [VALUE]
Gets or sets the current L<Jifty::Request> object.
Modified: jifty/trunk/lib/Jifty/Web/Form.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form.pm Tue Jan 15 15:55:13 2008
@@ -373,4 +373,17 @@
return '';
}
+=head2 DESTROY
+
+Checks to ensure that forms that were opened were actually closed,
+which is when actions are registered.
+
+=cut
+
+sub DESTROY {
+ my $self = shift;
+ warn "Action $_ was never registered (form was never closed)"
+ for grep {not $self->printed_actions->{$_}} keys %{$self->actions};
+}
+
1;
More information about the Jifty-commit
mailing list