[Catalyst] General Web- and OO-question

Cory Watson jheephat at gmail.com
Fri Mar 27 18:38:27 GMT 2009


2009/3/27 Rodrigo <rodrigolive at gmail.com>

>
> I think you are missing his point.  He wants to instantiate an object from
>> the form, but if he uses his Moose object then the things he wants to
>> validate (errors) will prevent him from getting an instance of his class.
>>  If "name" is required or isa 'Str' then if it gets an arrayref, he can't
>> use the object (as either it missing or being the wrong type throws an
>> exception).
>>
>
> Well, if the object gets an arrayref when it was expecting an Str then he
> can't use the object and it should throw an exception.
>

Picking this one to respond to, since Scott said the same thing.

I think the OPs point was to it's really easy to go from request params to a
constructed object.  He seems to think this a great Way To Do Things=99.  H=
is
problem was that you can't do that if the object throws an exception when he
tries to instantiate it.  This short-circuits his intent to use the type
constraints in Moose implicitly through the constructor.

The replies all point to the idea of mating the params to their attributes
and checking the constraints before instantiating.  These are all great, but
they don't solve his problem of using the object back on the form, think:

<input type=3D"text" value=3D"[% obj.attribute %]"...>

As for the OPs stated question: There's no one true way.  There's a bunch of
opinions. :)

-- =

Cory 'G' Watson
http://www.onemogin.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090327/81fd6=
fc7/attachment.htm


More information about the Catalyst mailing list