<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 21, 2008, at 3:01 PM, Sterling Hanenkamp wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">On Mon, Jul 21, 2008 at 2:17 PM, Jesse Vincent &lt;<a href="mailto:jesse@bestpractical.com">jesse@bestpractical.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hey Sterling,<br> <br> Can you tell us a bit about your 'Do' actions? I'm curious why just<br> subclassing 'Update' isn't easy enough.</blockquote><div><br>Because subclassing Update comes with all the baggage of all my record columns. I just wanted something simple that cares only about the record itself and possibly some extra parameters. For example, I might have a very simple task like this:<br> <br></div></div></div></blockquote><div><br></div><div>That feels like maybe we really want to make it easier to replace all the columns when you subclass.&nbsp;</div><div>Is Execute only an abstract action class?</div><div><br></div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_quote"><div>Jifty->web->new_action(<br>&nbsp;&nbsp;&nbsp; class => 'StartTimer',<br>&nbsp;&nbsp;&nbsp; record => $timer,<br>)->run;<br><br>which is really just a thick wrapper for saying:<br><br>$timer->start_timer;<br><br>Or I might want to have a simplified action for changing timers. For example, I can with a single form change either the start time or the stop time:<br> <br>package CubicleLog::Action::ChangeTime;<br>use base qw/ CubicleLog::Action::Record::Execute /;<br><br>use Jifty::Param::Schema;<br>use Jifty::Action schema {<br>param 'which' => is mandatory, valid_values are qw/ start stop /, default is 'start';<br> param 'new_time' => is mandatory;<br>};<br><br>sub validate_new_time { ... }<br><br>sub take_action {<br>&nbsp;&nbsp;&nbsp; my $self = shift;<br>&nbsp;&nbsp;&nbsp; my $which = $self->argument_value('which');<br>&nbsp;&nbsp;&nbsp; my $set_time = "set_${which}_time";<br> &nbsp;&nbsp;&nbsp; $self->record->$set_time($self->argument_value('new_time'));<br>&nbsp;&nbsp;&nbsp; $self->result->message(_('Set %1 time.', _($which)));<br>}<br><br>And then I can easily:<br><br>Jifty->web->new_action(<br> &nbsp;&nbsp;&nbsp; class => 'ChangeTime',<br>&nbsp;&nbsp;&nbsp; record => $timer,<br>&nbsp;&nbsp;&nbsp; arguments => {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; which => 'stop',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new_time => Jifty::DateTime->now,<br>&nbsp;&nbsp;&nbsp; },<br>)->run;<br><br>Perhaps Update is enough to do that. However, it didn't seem right. It seemed cluttered to include all the fields of ::Update with that.<br> <br>This is also wrapped up with this is another issue for me. Actions are a little hard for me to categorize since they just seem like functors with a bunch of extra traits attached to the parameters defining form characteristics, validation, canonicalization, etc. I feel like I want a really generic way of creating actions that just execute whatever function I've added to a model (like start_timer, stop_timer, etc.).<br> <br>It also seems like it should be possible to do this:<br><br>Jifty->web->new_action(<br>&nbsp;&nbsp;&nbsp; class => 'CreateSomething',<br>&nbsp;&nbsp;&nbsp; arguments => {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foo => 'bar',<br>&nbsp;&nbsp;&nbsp; },<br>)->run;<br> <br>as easily as this:<br><br>my $model = MyApp::Model::Something->new;<br>$model->create( foo => 'bar' );<br> <br>since CreateSomething is usually what I want to do, in case that involves special business logic. Then I can treat Something->create() as a low-level method and CreateSomething as the high level. Putting a bunch of before/after triggers into the Something model is a possible alternative, but there are things that are difficult when you do that. (For example, trying to perform the equivalent of Moose's "around" may lack an obvious solution.)<br> <br>I'm not sure if all of that is relevant to your question, but it's all connected in my mind.<br><br>Cheers,<br>Sterling<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <br> <br> -j<br> _______________________________________________<br> jifty-devel mailing list<br> <a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br> <a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel" target="_blank">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br> </blockquote></div><br></div> _______________________________________________<br>jifty-devel mailing list<br><a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br><a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br></blockquote></div><br></body></html>