[Seaside] State sharing between all sessions?

Avi Bryant avi.bryant at gmail.com
Tue May 24 10:53:48 CEST 2005


On 5/24/05, Martin J. Laubach <mjl at laubach.at> wrote:
>    I just got a request for a small web application which would require
> me to share some global state/variable between all session.
> 
>    Now that I think about it, I have no idea how to do that with
> Seaside, short of keeping the global state in a file on disk/in a
> database and re-reading it every time a request comes in. This would
> surely work, but it doesn't strike me as overly elegant.
> 
>    So, how do I share a variable between all Seaside sessions, so that a
> modification by session A is immediately seen in session B?

If the state is simple enough, you can do something like this:
1. keep the state in the image, in a global/class variable that all
sessions can access
2. every time it changes, write it to disk/db
3. every time the image starts up, read it from disk/db

This should work fine as long as:
- you don't need transactional semantics (for concurrency between sessions)
- all of your data can fit easily into RAM
- you can figure out a way to do (2) reasonably efficiently (either
the data is small enough that you can realistically write it all to
disk every time, or structured enough that you can easily
incrementally update the disk after a change)

Avi


More information about the Seaside mailing list