[albatross-users] Session management how-to?

Dave Cole djc at object-craft.com.au
Sun Jun 23 19:47:43 EST 2002


> I'm also writing up a few notes, as I learn things, on how-to do
> things in Albatross.  I've attached what I've done so far below. 
> This is preliminary, needless to say; I'm still learning Albatross. 
> But, if you you have any comments, I'm interested.  And, if you
> should feel that this would be of use to other Albatross users
> (after a bit more work, of course), let me know.

This is enormously valuable.  We are not able to do this as we are all
too close to the code now.

> =============================================================
> 
> 
> 
>                        Albatross How-to for Beginners
>                                       
>    Contents:
>      * Introduction
>      * How-to Structure an Object-based Application
>      * How-to Pass a Value to the Presentation
>      * How-to Pass a Value to the Controller
>      * How-to Manage Sessions

This is excellent.  Thanks for taking the time to document this.

[snip]

> How-to Manage Sessions
> 
>     1. How-to create a session -- Albatross does this for you
>        automatically. If the request from the browser contains
>        information about an existing session, that session is used,
>        otherwise Albatross creates a new session.
>     2. How-to remove a session -- You will need to explicitly do this.
>        (Albatross does not do this automatically.) If you have a page
>        from which the application can go no further, you could remove the
>        session on entering the page (the user will never leave the page -
>        but reloading the page will take them back to the beginning). Here
>        is an example:
>         class FinalPage:
>             def page_enter(self, ctx):
>                 ctx.remove_session()
>        Or, if the final page of your application contains a "Logout" or
>        "Exit" button, you can remove the session in the page_process
>        method of the class for that page like this:
>         class FinalPage:
>             def page_process(self, ctx):
>                 # Check for the logout button.
>                 if ctx.req_equals('logout'):
>                     ctx.remove_session()
>                     # Send the user back to the login page.
>                     ctx.set_page('login')

If you use the session server then idle sessions are deleted
automatically.  The session server will handle multiple web servers.
Session management is a non-issue for browser side sessions.

[snip]

>    Additional notes on session management:
>      * In order to run a session based application, you must start-up an
>        Albatross session server. The session-server sub-directory in the
>        Albatross distribution, contains an implementation of a session
>        server (al-session-daemon).
>      * If your application inherits it context and application classes
>        from SimpleSessionApp and SessionAppContext then Albatross stores
>        and saves session information in files in the local file system.
>      * In contrast, if your application inherits it context and
>        application classes from SimpleSessionFileApp and
>        SessionFileAppContext then Albatross stores and saves session
>        information in the session server, i.e. in memory in the session
>        server daemon. Note that if you change from memory-based session
>        storage to file-based storage, you will need to modify the call to
>        the application super class (). Add the session_dir keyword
>        argument, with the directory (a string) where you want Albatross
>        to store session state.

Small correction; SimpleSessionFileApp and SessionFileAppContext saves
sessions in the file system while SimpleSessionApp and
SessionAppContext save sessions in the session server via TCP socket.

- Dave

-- 
http://www.object-craft.com.au




More information about the Albatross-users mailing list