Zbigniew Lukasiak wrote:
On Mon, Feb 2, 2009 at 7:59 PM, Jason Gottshall <[email protected]> wrote:
Zbigniew Lukasiak wrote:
Maybe I am just being lazy now - but before I start digging too deep -
did you take into accout that some forms require loading stuff from
the DB?  It can happen in to cases:

1) loading SELECT choices lists - this one is easy - because it can be
done at initialisation as it does not depend on th request.

2) loading related forms for one to many relations - where you don't
know how many related forms you need until you have the main object -
i.e. until request time.  See Rose::HTML::Form::Repeatable.
Yes, I'm actually thinking of doing

 my $form = $class->new( app => $c );

so that the form can access model-related stuff as necessary. (This is safe
because RHTMLO automatically weakens any value passed to ->app). Would
something like that address your cases?

Hmm - I thought you mentioned something about caching the form objects
between requests?  Passing $c to the creator means you create the
forms on per request basis.   If you like the caching idea - then what
would be needed is a kind of two phase initialisation.  First you
create a prototype - and then you add the necessary repeatable
sub-forms on per request basis to it (of course this is only needed if
you use repeatable sub-forms).

Yeah, I gave up on caching for now, mostly due to concerns about form mutability. And it's a premature optimization that will be harder to code for given the other factors I'm dealing with, so I don't want to think about it yet.

The example you cite raises precisely one of my concerns: if you start with a cached "prototype" form and add subforms per-request, you have to make sure you include some sort of cleanup or reset routine to clear out the temporary subforms from the previous request. By extension, many various temporary modifications to the form structure (other than merely adding subforms) are possible, so we'd need to develop some kind of generic mechanism for removing these modifications. My brain isn't ready to tackle that problem right now, so I'm blissfully ignoring it :-)


--
Jason Gottshall
[email protected]


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to