[Seaside] Re: Application/Session Objects

Richard Huxton dev at archonet.com
Wed Feb 22 17:46:04 UTC 2006


Yanni Chiu wrote:
> All WAComponent instances (i.e. an instance of your custom subclass)
> can always find their corresponding session instance via "self session".
> As Philippe has posted, you can create your own subclass of WASession,
> to hold your database connection and other objects. I just create a
> generic session with one instance variable that holds a dictionary.
> That way I don't have to add/remove new slots, during development.
> It's somewhat inconvenient to use though (#at: and #at:put: vs. 
> getter/setter).

Excellent - that's the sort of thing I was planning to do. Thanks for 
the pointer.

> Instead of using the config app., I prefer to code in the #initialize
> method something like:
> 
>     (self registerAsApplication: 'foobar')
>         preferenceAt: #sessionExpirySeconds put: 8*60*60;
>         preferenceAt: #sessionClass put: PUISession;
>         yourself.
> 
> To close/release your database connection your WASession subclass
> should implement an #unregistered method to clean up the connection.
> #unregistered gets called some time after the session expiry.

Hmm - that's useful, but what if I want to re-use the connection after 
the request? That is, I'd like to be able to do:
1. hook a request start, claim a DB connection from the pool
2. do some database queries
3. hook the request end, return connection to the pool

Crucially, #3 might restrict that connection for this session only or 
allow any session to re-use it.

I'd hate to have an open transaction floating around for an hour while I 
wait for the session to expire.

> BTW, Richard, aren't you a regular in postgresql. I had to check
> what list I was reading. I'm curious what led you to Seaside.
> Anyhow, welcome aboard.

Yep - that's me. I do a fair bit of web-based application work and I've 
been looking around for improvements to my way of working. I've looked 
at Ruby on Rails and Catalyst (Perl) but they mostly seem to handle 
problems I've already solved in-house. I'm particularly not worried 
about templating - most of my stuff is code-generated HTML forms, not 
web-pages as such.

Seaside looks very interesting, and I like the interactive debugging, 
closures continuations etc. Hate the Smalltalk syntax, the way 
underscore has been stolen and I'm worried about deployment/management 
and performance issues. It's early days though, so this is still very 
much first impressions for me.

I've got some scripts I'm adapting to generate my Smalltalk model from 
my DB schema+extras and that to generate forms based on the model via a 
set of plugin renderers. I've got a different view to most, because I'm 
viewing my database as the heart of the system, with the application 
fitting to it rather than the other way around.

-- 
   Richard Huxton
   Archonet Ltd


More information about the Seaside mailing list