[Catalyst] General Web- and OO-question

Hans Dieter Pearcey hdp.perl.catalyst.users at weftsoar.net
Sat Mar 28 00:41:12 GMT 2009


On Fri, Mar 27, 2009 at 01:38:27PM -0500, Cory Watson wrote:
> 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 .  His
> 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.

I've thought a few times about making an attribute metaclass that lets you ask
for validity on-demand rather than always checking at object creation time; the
problem with that is that it's a pretty big shift from how objects normally
work, and I'm not sure what kind of subtle weird behaviors might arise.

Another option mentioned elsewhere in the thread is a proxy object.  Moose
certainly exposes enough metainformation to make this possible, but I think
there'd still be a good amount of fiddly work required; for example, you'd
either have to use AUTOLOAD or generate anonymous classes on the fly, or switch
to an explicit proxy API.

I don't think any of this is insurmountable; the biggest reason I haven't tried
one or all of these is that I'm lazy.

hdp.



More information about the Catalyst mailing list