develooper Front page | perl.module-authors | Postings from October 2005

Another naming question, this time session-related

Thread Next
From:
Dave Rolsky
Date:
October 6, 2005 13:01
Subject:
Another naming question, this time session-related
Message ID:
Pine.LNX.4.63.0510061452410.25377@urth.org
So it looks like Rose::URI does what I want (name notwithstanding ;) so I 
probably won't release my URI code (though I could if people are desperate 
to see it).

Next up on the agenda in breaking MasonX::WebApp into tiny pieces ...

It provides a simple API for storing messages (errors and non-errors) and 
query/form data in the session (basically to help repopulate a form after 
a redirect on an error).

It uses Apache::Session::Wrapper to create the session and then has a very 
simple API like this:

   add_error( ... )
   # if given an exception object tries to get some useful info out of it,
   # but can just take a string or hashref or whatever.

   add_message( ... )
   # save a non-error message like "you are logged in"

   save_form_data( \%hash )
   # socks away that form data for you

   errors()
   messages()
   form_data()
   # return stuff

   reset()
   # remove all errors, messages, and form data from the session

   session()
   # get the underlying session hash

I'll probably also have:

   errors_destructive()
   messages_destructive()
   # return stuff and delete it from the session


So the question is what to call this?  I think it's pretty useful as it 
encapsulates a very common use of sessions with a slightly higher level 
API.

It's also worth noting that it is not actually web application specific 
since Apache::Session (and Apache::Session::Wrapper) despite the name are 
not mod_perl only.

So I was thinking of a name like Session::MessagesAndFormData but that's 
got two strikes.  One, it's a new top-level namespace (there is 
Session.pm, but it's not really maintained nor does anyone use it, I'd 
guess) and two, the second part is goofily verbose.


-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About