Re: More thoughts on Forge->Formo conversion

Chad Kieffer <[email protected]> Sat, 27 Apr 2013 08:47:47 -0600
Newsgroups gmane.comp.web.gallery.devel
Message-ID <[email protected]>
--===============8201513837546394100==
Content-Type: multipart/alternative;
	boundary=Apple-Mail-214AEC1E-DB38-4C88-82C1-EBFA9EB49B9F
Content-Transfer-Encoding: 7bit


--Apple-Mail-214AEC1E-DB38-4C88-82C1-EBFA9EB49B9F
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable

I was thinking in the context of REST. Yes, makes sense.

On Apr 27, 2013, at 5:20 AM, Shad Laws <shad-xpYdmXCiSuZWk0Htik3J/[email protected]> wrote:

> I haven't dug too deeply into this piece of the puzzle yet, but my initial=
 thought is to still leave these as two separate action routes.  This seems t=
o mirror what we use in many other places, where each of the CRUD functions h=
as an independent route, which maps pretty easily to ORM, SQL, REST, etc. fu=
nctions.  Seem reasonable?
>=20
> Shad
>=20
>=20
> On 26 April 2013 20:39, Chad Kieffer <[email protected]> wrote:
>> +1 from me, too. For clarity, will separate action routes be kept or will=
 add/edit be replaced with something like save?
>>=20
>> On Apr 24, 2013, at 10:42 AM, Bharat Mediratta <[email protected]> wrote=
:
>>=20
>>>=20
>>> Fantastic.  I never liked the way we had this split up before so it's ni=
ce to see that Formo can streamline it for us.
>>>=20
>>> I've also never been happy with our form/{add,edit}/ routing - that was a=
 framework put in place before it was clear what the true need would be and i=
t's only used in 9 places.  I'd be happy to see that routing go away and let=
 each controller do it in a more ad hoc approach.  Take a look at that while=
 you're in there and let me know what you think.
>>>=20
>>> -Bharat
>>>=20
>>>=20
>>> On Wed, Apr 24, 2013 at 1:13 AM, Shad Laws <shad-xpYdmXCiSuZWk0Htik3J/[email protected]> wrote:
>>>> Hey everyone,
>>>>=20
>>>> I'm working on getting acquainted with Formo a bit more, and it seems l=
ike the default, expected actions of Formo is a bit different than how we we=
re using Forge in Gallery 3.0.x.
>>>>=20
>>>> Before, we usually (but not always) had a separate controller action fo=
r showing a form vs. validating a form (e.g. action_edit() and action_save()=
).  Also, it was common to have a third function generate the form for us, s=
o we ended handling the form in three places.
>>>>=20
>>>> It seems that the default, expected behavior of Formo is to do this in o=
ne place with one action.  It's smart enough to figure out if we have post d=
ata or not, and therefore if we are in "edit" or "save" mode (following the e=
xample).  An example:
>>>>=20
>>>> public function action_edit() {
>>>>   $form =3D Formo::form(...)
>>>>           ->....; // build form, load with default values.
>>>>=20
>>>>   if ($form->load()->validate()) {
>>>>     // load() gets the values from post/files and fills the values,
>>>>     // then validate() checks stuff and does nothing if the form isn't
>>>>     // yet sent (nothing loaded) or adds errors if it was.
>>>>=20
>>>>     // Do some more stuff... then:
>>>>     Message::success(t("Done!"));
>>>>     // And/or:
>>>>     $this->redirect("somewhere/else");
>>>>   }
>>>>  =20
>>>>   $view =3D .....;
>>>>   $view->form =3D $form;
>>>>=20
>>>>   $this->response->body($view);
>>>> }
>>>>=20
>>>> I can overload a couple Formo classes to ensure that each form contains=
 and validates our csrf, similar to what we did with Forge.
>>>>=20
>>>> Does this seem like a reasonable approach?  Is there some other reason w=
hy we intentionally divided these up into multiple actions before?
>>>>=20
>>>> Take care,
>>>> Shad
>>>>=20
>>>> -----------------------------------------------------------------------=
-------
>>>> Try New Relic Now & We'll Send You this Cool Shirt
>>>> New Relic is the only SaaS-based application performance monitoring ser=
vice
>>>> that delivers powerful full stack analytics. Optimize and monitor your
>>>> browser, app, & servers with just a few lines of code. Try New Relic
>>>> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_=
apr
>>>> __[ g a l l e r y - d e v e l ]_________________________
>>>>=20
>>>> [ list info/archive --> http://gallery.sf.net/lists.php ]
>>>> [ gallery info/FAQ/download --> http://gallery.sf.net ]
>>>=20
>>> ------------------------------------------------------------------------=
------
>>> Try New Relic Now & We'll Send You this Cool Shirt
>>> New Relic is the only SaaS-based application performance monitoring serv=
ice=20
>>> that delivers powerful full stack analytics. Optimize and monitor your
>>> browser, app, & servers with just a few lines of code. Try New Relic
>>> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_a=
pr
>>> __[ g a l l e r y - d e v e l ]_________________________
>>>=20
>>> [ list info/archive --> http://gallery.sf.net/lists.php ]
>>> [ gallery info/FAQ/download --> http://gallery.sf.net ]
>=20

--Apple-Mail-214AEC1E-DB38-4C88-82C1-EBFA9EB49B9F
Content-Type: text/html;
	charset=utf-8
Content-Transfer-Encoding: 7bit

<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I was thinking in the context of REST. Yes, makes sense.</div><div><br>On Apr 27, 2013, at 5:20 AM, Shad Laws &lt;<a href="mailto:shad-xpYdmXCiSuZWk0Htik3J/[email protected]">shad-xpYdmXCiSuZWk0Htik3J/[email protected]</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I haven't dug too deeply into this piece of the puzzle yet, but my initial thought is to still leave these as two separate action routes. &nbsp;This seems to mirror what we use in many other places, where each of the CRUD functions has an independent route, which maps pretty easily to ORM, SQL, REST, etc. functions. &nbsp;Seem reasonable?<div>

<br></div><div style="">Shad</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 26 April 2013 20:39, Chad Kieffer <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>+1 from me, too. For clarity, will separate action routes be kept or will add/edit be replaced with something like save?</div>

<div><br>On Apr 24, 2013, at 10:42 AM, Bharat Mediratta &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt; wrote:<br><br></div><div><span></span></div><blockquote type="cite"><div><div dir="ltr">

<br><div>Fantastic. &nbsp;I never liked the way we had this split up before so it's nice to see that Formo can streamline it for us.</div><div><br></div><div>I've also never been happy with our form/{add,edit}/ routing - that was a framework put in place before it was clear what the true need would be and it's only used in 9 places. &nbsp;I'd be happy to see that routing go away and let each controller do it in a more ad hoc approach. &nbsp;Take a look at that while you're in there and let me know what you think.</div>



<div><br></div><div>-Bharat</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 24, 2013 at 1:13 AM, Shad Laws <span dir="ltr">&lt;<a href="mailto:shad-xpYdmXCiSuZWk0Htik3J/[email protected]" target="_blank">shad-xpYdmXCiSuZWk0Htik3J/[email protected]</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey everyone,<div><br></div><div>I'm working on getting acquainted with Formo a bit more, and it seems like the default, expected actions of Formo is a bit different than how we were using Forge in Gallery 3.0.x.</div>





<div><br></div><div>Before, we usually (but not always) had a separate controller action for showing a form vs. validating a form (e.g. action_edit() and action_save()). &nbsp;Also, it was common to have a third function generate the form for us, so we ended handling the form in three places.</div>





<div><br></div><div>It seems that the default, expected behavior of Formo is to do this in one place with one action. &nbsp;It's smart enough to figure out if we have post data or not, and therefore if we are in "edit" or "save" mode (following the example). &nbsp;An example:</div>





<div><br></div><div><font face="courier new, monospace">public function action_edit() {</font></div><div><font face="courier new, monospace">&nbsp; $form = Formo::form(...)</font></div><div><font face="courier new, monospace">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;....; // build form, load with default values.</font></div>





<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">&nbsp; if ($form-&gt;load()-&gt;validate()) {</font></div><div><font face="courier new, monospace">&nbsp; &nbsp; // load() gets the values from post/files and fills the values,</font></div>





<div><font face="courier new, monospace">&nbsp; &nbsp; // then validate() checks stuff and does nothing if the form isn't</font></div><div><font face="courier new, monospace">&nbsp; &nbsp; // yet sent (nothing loaded) or adds errors if it was.</font></div>





<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">&nbsp; &nbsp; // Do some more stuff... then:</font></div><div><font face="courier new, monospace">&nbsp; &nbsp;&nbsp;Message::success(t("Done!"));</font></div>





<div><font face="courier new, monospace">&nbsp; &nbsp; // And/or:</font></div><div><font face="courier new, monospace">&nbsp; &nbsp; $this-&gt;redirect("somewhere/else");</font></div><div><font face="courier new, monospace">&nbsp; }</font></div>





<div><font face="courier new, monospace">&nbsp;&nbsp;</font></div><div><font face="courier new, monospace">&nbsp; $view = .....;</font></div><div><font face="courier new, monospace">&nbsp; $view-&gt;form = $form;</font></div>

<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">&nbsp; $this-&gt;response-&gt;body($view);</font></div><div><font face="courier new, monospace">}</font></div>

<div><br></div><div>I can overload a couple Formo classes to ensure that each form contains and validates our csrf, similar to what we did with Forge.<br></div><div><br></div><div>Does this seem like a reasonable approach? &nbsp;Is there some other reason why we intentionally divided these up into multiple actions before?</div>





<div><br></div><div>Take care,</div><div>Shad</div></div>
<br>------------------------------------------------------------------------------<br>
Try New Relic Now &amp; We'll Send You this Cool Shirt<br>
New Relic is the only SaaS-based application performance monitoring service<br>
that delivers powerful full stack analytics. Optimize and monitor your<br>
browser, app, &amp; servers with just a few lines of code. Try New Relic<br>
and get this awesome Nerd Life shirt! <a href="http://p.sf.net/sfu/newrelic_d2d_apr" target="_blank">http://p.sf.net/sfu/newrelic_d2d_apr</a><br>__[ g a l l e r y - d e v e l ]_________________________<br>
<br>
[ list info/archive --&gt; <a href="http://gallery.sf.net/lists.php" target="_blank">http://gallery.sf.net/lists.php</a> ]<br>
[ gallery info/FAQ/download --&gt; <a href="http://gallery.sf.net" target="_blank">http://gallery.sf.net</a> ]<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>------------------------------------------------------------------------------</span><br><span>Try New Relic Now &amp; We'll Send You this Cool Shirt</span><br><span>New Relic is the only SaaS-based application performance monitoring service </span><br>

<span>that delivers powerful full stack analytics. Optimize and monitor your</span><br><span>browser, app, &amp; servers with just a few lines of code. Try New Relic</span><br><span>and get this awesome Nerd Life shirt! <a href="http://p.sf.net/sfu/newrelic_d2d_apr" target="_blank">http://p.sf.net/sfu/newrelic_d2d_apr</a></span></div>

</blockquote><blockquote type="cite"><div><span>__[ g a l l e r y - d e v e l ]_________________________</span><br><span></span><br><span>[ list info/archive --&gt; <a href="http://gallery.sf.net/lists.php" target="_blank">http://gallery.sf.net/lists.php</a> ]</span><br>

<span>[ gallery info/FAQ/download --&gt; <a href="http://gallery.sf.net" target="_blank">http://gallery.sf.net</a> ]</span></div></blockquote></div></blockquote></div><br></div>
</div></blockquote></body></html>
--Apple-Mail-214AEC1E-DB38-4C88-82C1-EBFA9EB49B9F--


--===============8201513837546394100==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
--===============8201513837546394100==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]
--===============8201513837546394100==--