[Seaside] [how to?] sesssion expiration

Avi Bryant avi at beta4.com
Tue Jan 20 20:42:35 CET 2004


On Jan 20, 2004, at 8:35 AM, Vaidas Didzbalis wrote:

> Hello,
> I do not understang usage of isolate: ...
> How to modify Counter example, if I want user not be able press back 
> and  submit if value of counder is greater then 10?

Well, you can't quite use #isolate: for that, but you can use the 
underlying WATransaction mechanism.  First let me give an example of 
what that would look like, then I'll try to explain:

WAComponent subclass: #WACounter
	instanceVariableNames: 'count txn'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Seaside/Examples-Test'

WACounter>>initialize
	self session registerObjectForBacktracking: self.
	count _ 0.
          "new code"
          txn _ WATransaction new.
	self session addFilter: txn

WACounter>>increment
	count _ count + 1.
          count > 10 ifTrue: [self session removeFilter: txn.  txn 
close].

What does this do?  Well, the session keeps a stack of "filters" that 
you can add to or remove from.  Whenever a new page is generated, part 
of the information that is recorded about it is what the active filter 
objects are.  When someone tries to use that page, their request first 
passes through whichever filters were active.  In this case, we are 
putting an instance of WATransaction on the filter stack for the period 
between the counter being created and the counter reaching 10.  That 
means that any interactions with any pages generated in that time will 
have to pass through the WATransaction.

What WATransaction does is very simple.  At first, it lets all requests 
through, and they get processed normally.  However, once you send it 
#close, it will refuse any requests using WASession>>pageExpired.  
Since we close the txn once we hit 10, then any attempts to use the 
pages generated before we hit 10 will fail.

#isolate: is just a convenience wrapper around this - if you look at 
its implementation you'll find it straightforward.



More information about the Seaside mailing list