First, I create a subclass of WASession, say TGPMSession, with some extra instance vars:

WASession subclass: #TGPMSession
	instanceVariableNames: 'user db '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Techgame-Seaside'

And now for some lazy initialization on the GOODS database:

TGPMSession>>db
      ^ db ifNil: [db := KKDatabase onHost: (self dbHost) port: (self dbPort)].

( for the dbHost and dbPort methods, let's take a side trip...)

This will initialize the Database connection; then I create convenience methods for getting at my domain objects stored in the database. In this case, we are doing a login widget, so those are the methods I'll put on there. First, I need a list of users:

users
   ^ self db root at: 'Users'

... so that I can use it conveniently get a User object from the login string typed in on a form:

userForLogin: aLogin
    ^ self users detect: [:user | user login = aLogin]

We also need a way to set the current user logged in on the session for easy access from any component in the app:

user: aUser
   user := aUser
user
   ^ user

The tricky part

We will now override a method from the session that allows us to have our GOODS database automatically reflect the changes we make to objects in our Seaside application:

withEscapeContinuation: aBlock
   ^ (self db) commitWithRetry: [super withEscapeContinuation: aBlock]

Next: the Login component

Top: Using GOODS with Seaside