[Seaside] Transactions, database connections, indices, GOODS and Seaside

Avi Bryant avi at beta4.com
Thu May 13 01:44:40 CEST 2004


On May 12, 2004, at 1:24 PM, C. David Shaffer wrote:

> So, how to people deal with this?  Just a push in the right direction 
> would be helpful.  Avi, if you recall I asked you about this at your 
> tutorial at SS last year and walked away thinking that it would be 
> obvious once I got started.  Now, a full year later I can't remember 
> why it should be obvious :-)

Each Seaside session is guaranteed to only be processing one request at 
a time.  So you're actually perfectly safe to store the current 
transaction in the session for the duration of a request.  The best 
override point is probably #responseForRequest: - something like this, 
I guess:

responseForRequest: aRequest
   currentTransaction := self newTransaction.
   [super responseForRequest: aRequest]
	ensure: [currentTransaction commit.
		     currentTransaction := nil].

There may be some subtleties here with error handling we'll have to 
work out (Julian?), but that's the basic idea.

Or you can use a dynamic variable rather than storing it in the session 
- Seaside actually has its own WADynamicVariable implementation which 
you might find useful.  To use it, define a subclass for each variable 
you want dynamic access to, then send #use:during: and #value (both on 
the class side) to set and get the value respectively.

Avi



More information about the Seaside mailing list