[Seaside] Where to store db connection value?

Julian Fitzell julian at beta4.com
Wed Oct 19 17:04:14 UTC 2005

Well, certainly not the only way but one option is to use WADynamicVariable:

Create a subclass of WADynamicVariable (say MYCurrentDatabase)

Then, in your session (maybe in #performRequest: - can't remember 
exactly where the best place to plug in is and I'm at work at the 
moment), you do something like:

performRequest: aRequest
	^ MYCurrentDatabase use: self database during: [super performRequest: 

Now you can access the database from anywhere (during request handling) 
by doing "MYCurrentDatabase value".  You could even add:

    ^ MYCurrentDatabase value

to make things cleaner.

You might need to tweak that a bit; as I said, I can't quite remember 
the best place to plug it in (and I was doing it most recently with 
Seaside 2.3 anyway) but you can look at how WACurrentSession does it 
because it's doing pretty much the same thing.

Hope that's helpful,


Chad Nantais wrote:
> My application is composed of Models and Views (Seaside Components). 
> The models (rather than the views) need to access the data I have
> stored in a dictionary object.  I have multiple data stores
> ('development' and 'testing').  I have added a session configuration
> variable (dataStoreName) in a subclass of WASessionConfiguration that
> holds the name of the data store I want to use (eg. 'testing' for unit
> tests). However, since the models subclass Object and are not
> sublasses of WAComponent, I can't get them to access the value of
> MYSessionConfiguration>>dataStoreName
> How can I give my models access to the value of dataStoreName so they
> can access data from the configured dataStore?
> Chad
> --
> Chad Nantais, CISSP
> "Let him who would move the world first move himself." --Socrates
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the Seaside mailing list