> > But that' s my problem: One one web page I do not get all attributes I need > to instantiate the object correctly. Simple unrealistic example. One one > page > the user can enter a "name" on the second the "age". The object can be > instatiated > if you provide a valid name and age.
Well, just instantiate an empty object then use the accessors Moose creates for you automagically. Accessors validate as well: sub start_up : Local { $c->session->{obj} = new MyClass(); } sub submit_name : Local { $c->session->{obj}->name( $c->req->params->{name} ); } sub submit_age : Local { $c->session->{obj}->age( $c->req->params->{age} ); } > But I can't instatiate > the object because it throws an exception because age is not valid, isn't > it? > > Or does Moose check constraints only on provided attributes. This can't be > true > with "required" attributes, can it? > As long as the attribute is not "required => 1", no exception is thrown. > > > Catalyst::Model::Adaptor may also come in handy if > > you feel you need to turn your class into a model. > > What do you mean with that? > First, read up on the Model part of MVC, that's where most of your application storage should end up. Have you decided what are you going to do with the object once it's filled up? --rodrigo
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/