2009/11/3 Octavian Râşniţă <orasn...@gmail.com>: > From: "Carl Franks" <fireart...@gmail.com> > 2009/11/2 Octavian Râşniţă <orasn...@gmail.com>: >> >> From: "Carl Franks" <fireart...@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.
No, cloning IS needed :) In perl, any object is a reference. A cache is just a fancy name for a place to store something. Without cloning, every user would be getting the exact same object, and would overwrite each others internal state - submitted(), valid_names(), errors(), etc. $form->clone() creates a new object (a new reference) and uses Storable::dclone() to ensure any other references, such as hashrefs, arrayrefs are also cloned Carl _______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu