[Catalyst-dev] Another Session discussion

Matt Pitts mpitts at a3its.com
Wed Feb 4 16:55:51 GMT 2009


I started hacking on a Moose-based Session plugin that uses Roles and
delegation to a specified $c->model for storage. My main justification
for this work is to just get my own gears turning, so these are just
ideas, and I'd be happy to scrap it there's already something started.
Here's what I've got so far...


A Roles distribution:

  Catalyst::Role::Session 
    - the basic methods necessary for other stuff to use session
mechanisms ($c->has_role('Catalyst::Role::Session'))
    - interface:
        requires 'session';
        requires 'sessionid';
        requires 'session_is_valid';
        requires 'delete_session';
        requires 'delete_session_reason';
        requires 'session_expire_key';
        requires 'delete_expired_sessions';

  Catalyst::Role::Session::Flash 
    - the basic methods necessary for flash functionality
    - interface
        requires 'flash';
        requires 'clear_flash';
        requires 'keep_flash';

  Catalyst::Role::Session::Store 
    - the basic methods necessary to implement a storage backend
    - interface
        requires 'get_session_data';
        requires 'set_session_data';
        requires 'delete_session_data';
        requires 'delete_expired_sessions';
        requires 'generate_session_id';
        requires 'session_is_valid';


The Main P::Session distribution:

  Catalyst::Plugin::Session
    - consumes Catalyst::Role::Session
    - gets $self->_session_model from
$c->model($self->_session_model_class)
    - ensures that
$self->_session_model->has_role('Catalyst::Role::Session::Store')
    - delegates many functions to $self->_session_model

  Catalyst::Model::Session::Cookie
    - consumes Catalyst::Role::Session::Store

  Catalyst::Model::Session::DBIC
    - consumes Catalyst::Role::Session::Store

  Catalyst::Model::Session::ImaginarySomething
    - consumes Catalyst::Role::Session::Store

And that's about as far as I got, I thought I'd get opinions before more
model starts coming about of my head. BTW, none of this actually works
yet, it's just conceptualize code. Oh, and I'm not even thinking about
compat right now.

v/r

-mattpitts (invinity)




More information about the Catalyst-dev mailing list