Re: [Cgi-session-user] proposed refinements to load() and find() interfaces
Brought to you by:
sherzodr
From: Matt L. <mle...@cp...> - 2006-06-10 18:50:43
|
On 6/10/06, *Mark Stosberg* <ma...@su...> wrote: "load" vs "_load" is not clear. load is part of the documented public interface, _load is not. This is a change to internals, nothing else. I propose instead the following: 1. A named-parameters interface for load(): load( dsn => $dsn, dsn_args => \%dsn_args, query => $query, update_atime => 1, # defaults to 1 ); 2. And also a named-parameters interface for find() find( dsn => $dsn, dsn_args => \%dsn_args, code => inspect( look => 'closely'), update_atime => 0, # defaults to 0 here! ) Notice that "dsn" and "dsn_args" are now together, which is nice. Also notice that the "coderef_args" is not needed. Instead, higher order functions can used, which have worked well in the Data::FormValidator 4.0 interface. If coderefs args would be needed, a closure can be returned whic provides them. Here's an example what "inspect()" might look like: sub inspect { my %args = @_; return sub { my $session = shift; my $coderef_args = \%args; # do something... } } The point of the change that I'm making is to allow us to inspect the session as the user has left it without changing anything. I strongly feel that the current behavior of find is wrong. find is supposed to manage the sessions as the user has left them. If you wish to add something to the session, no problem. Call param on the session as you normally would and the changes will be made but the access time will not. If someone really wants to update the access time, then they can either load the session or we can add an update_atime method. Matt, If you agree with these refactorings, would you mind coding them up? I wouldn't mind coding them if I agreed with them =) -Matt |