[Seaside] Seaside philosophy and real life implementations

Barger barger at barnet.sk
Tue Jan 18 18:11:14 CET 2005

Avi, I already found some solution, and here is my idea :

Seaside application web server ignore all static link inputs, and also inputs from expired sessions
by starting new session. So i modified first these methods :

WASession>>performRequest: aRequest
	| key continuation |
	key := aRequest fields at: self actionField ifAbsent: 
		[ | msg tok |
		tok := ((aRequest url) findTokens: '/').
		msg := OrderedCollection new. 
		(tok size > 2) ifTrue: [  3 to: (tok size) do: [ :i | msg add: ( tok at: i )]].							
		^ self start: aRequest msg: msg.				
	continuation := continuations at: key ifAbsent: [^ self unknownRequest: aRequest].
	continuation value: aRequest

Block after ifAbsent is changed from ^self start: to ^self start: msg: and flow is redirected here:

 WASession>>start: aRequest msg: aMessage
	| app |
	app := self mainClass.
	(app new respondsTo: #start:msg:) ifTrue: [^ app new start: aRequest msg: aMessage].
	app new start: aRequest

and then to LoopMain ( this could be also another Class, but for now i will try to keep it simple ) :

WARenderLoopMain>>start: aRequest msg: aMessage
	| root aMsg mArg mSize rClass |
	root:= self createRoot.
	mSize := aMessage size.
	mSize > 0 ifTrue:
	mSize > 1 ifTrue: [aMsg := ((aMessage at: 1),':') asSymbol.  mArg := (aMessage allButFirst) asArray. ]
			  ifFalse: [ aMsg := (aMessage at: 1) asSymbol.  mArg := Array new: 0  ].
	rClass := root class whichClassIncludesSelector: aMsg.
	(rClass className = 'UndefinedObject')
	    ifFalse: [ 	(('*jb-seaside-pathmsg') = (rClass whichCategoryIncludesSelector: aMsg)) ifTrue:
					[  root perform: aMsg withArguments: mArg. ].
	^ (WARenderLoop new root: root ) run.

Main idea is that from path '/application/message/parameter'  invoke application>>message: parameter
This is all of the seaside-core patch.

Now we need to prepare application ( note that new appl. method must be in cathegory named *jb-seaside-pathmsg 
or whatever exactly same as you have in LoopMain check - this is simple protection from unwanted external calls )

WACounter>>set: aValue
count := aValue.

And finaly we can try it :


It will return new session, with counter set to 123.

This is just the idea how to initialize sessions by using parameters from static url, and how to add seaside application ability to handle static links and than also do better SEO. I will try to work more on that, but for now this is just the main idea. So i want to hear your opinion, and if this way handling will not break seaside philosophy someway.

Thanks, Jan Barger

More information about the Seaside mailing list