[html-formfu] Speed of processing

Octavian Râşniţă orasnita at gmail.com
Tue Nov 3 06:26:12 GMT 2009


From: "Carl Franks" <fireartist at gmail.com>
2009/11/2 Octavian Râşniţă <orasnita at gmail.com>:
> From: "Carl Franks" <fireartist at gmail.com>
> ...
>>
>> Ok, but if each user should have its own form, then how does the cache
>> help
>> the users?
>> I thought that the forms could be saved without the data they contain...
>> only the structure of the form, without any data, which should be the 
>> same
>> for all users.
>> In that case the program wouldn't need to parse the config files and
>> wouldn't need to re-generate the form object, but only set that object
>> with
>> the data supplied by the user. Is it possible something like this?
>
> Kahlil didn't say each user needed their own cache, he was describing
> a reason why a cache that doesn't clone the form object would fail.
>
> Ok, but this is what I don't understand. If the form cache can contain 
> just
> the form structure, with no other information or data or errors, then why
> can't 2 or more users use it?
> (Something like the use of cached TT templates by all users)

2 or more users can share it - I don't know where you got that from :)

Well, I think I understand now... or not? :-)
A user accesses the form. This creates a cached version of the form. A 
second user gets the form from the cache and adds data to it. Without 
cloning the form, the data would be stored by reference in the cache or 
something like that, and the other users would also get it.
I just thought that once the user gets the form from the cache, no matter 
what it does to that form, his changes can't propagate back to the cache so 
no cloning was needed... I hope I understood correctly.

> Is it possible to hard code a form in a template instead of defining it in 
> a
> configuration file and then use HTML::FormFu for processing it, for 
> setting
> the constraints, the validators, filters...?

There are 2 distinct uses of forms:
1) rendering
2) processing
Most of the time you don't really have to think about separating them,
but you can.
As long as your hardcoded form's action="URL" points to a controller
action that loads an appropriate FormFu object containing fields with
the same field-names, it'll work fine.
So, yes, you'll still need a form config file for the login form, but
you'll only need to load it when the user hits the /login action, not
for every other hit.
Carl

That's great!

Thank you.

Octavian




More information about the HTML-FormFu mailing list