One important question when building applications is how to save their data. This question is not directly linked to Seaside, but we want to provide some possible solutions to help you get started. Several solutions exist to save your data. We will present some of the ones that are available in Squeak and that are based on open-source software. We will cover multiple solutions based on image snapshots, active record-like behavior, and object-oriented databases. We will not cover in detail Object-Relational mapping solutions such as GLORP (an open-source object-relational mapper). The book “An Introduction to Seaside” by Michael Perscheid et al. presents a nice introduction to GLORP and we point the interested reader to this book. Cincom offers WebVelocity (see Chapter 3) to support the definition of web applications using Seaside and scaffolding of applications. For the persistency, WebVelocity uses GLORP. There are some efforts to support OpenDBX in Squeak. The list of support will certainly grow and we may extend it as well.
The purest definition of “persistence” is capturing the state of memory to secondary storage (disk) so that work on the meaningful object model may continue later; and this is the primary purpose of any persistence framework. Another useful purpose, however, is to accommodate very large models that cannot fit entirely in RAM. Capable persistence frameworks manage large models by paging portions of the model into RAM as necessary for consumption or updates, and paging it out to make room for other parts of the model. One job of an object-database is to do this as transparently to the developer as possible.
Of course, Smalltalk vendors offer specific solutions for persistency ranging from object-relational mapping to object-oriented databases. GemStone is an object database that natively runs Seaside (see Chapter 4). The GemStone approach offers a robust and scalable object-oriented environment for Seaside. With GemStone you don’t have to think about persistency at all, the fact that objects are persistent in an industrial strength database is part of the language. GemStone offers GLASS, a 4 GiB persistent image that just magically solves most of your persistency problems. GLASS can be a really important option for persistency when you really need to scale in the Seaside world; however, it requires a 64 bit server and introduces the small additional complexity of changing to a different Smalltalk and learning its class library.
A little note. Most applications don’t need to scale. They need to be robust and solve client problems. Most real world applications are written to run small businesses. In all likelihood, scaling is not and probably won’t ever be your problem. We might like to think we’re writing the next YouTube or Twitter, but odds are we’re not. You can make a career just replacing spread sheets with simple applications that make people’s lives easier without ever once hitting the limits of a single Squeak image (such was the inspiration for DabbleDB), so don’t waste your time scaling (yet). Spend your time on solving client problems and building robust software. If scaling ever becomes a problem, be happy, it’s a nice problem and your clients will pay for it.
In contrast to other “web frameworks” Seaside does not provide a ready-made persistency solution for you. We consider this to be an advantage, Seaside lets you choose the database technology that fits your needs the best and concentrates on what it is strong at, web application development.
In this chapter we will present several persistency solutions of various degrees of scalability and simplicity. First we will describe some simple image-based and object serialization solutions. Then we present SandstoneDB which offers an Active Record-style API (even if it does not offer transactional semantics, concurrent accesses) and use the image as a persistency. Finally we present Magma: an object-oriented database based on a write-barrier. This approach is similar to the one of GOODS.