Seaside development with GNU Smalltalk

Tagged:  •    •    •    •    •  

The next release of GNU Smalltalk will include support for Seaside. This blog post is a short tutorial, which will show how to make your first Seaside component.

To follow this tutorial you need GNU Smalltalk 3.0a (which will be available from later today) or a later version.

One of the new features in 3.0a and later is the ability to run an image in the background and control it from the shell. For example, you can try these commands:

$ gst-remote --daemon
$ gst-remote --eval '100 factorial'
$ gst-remote --kill

where you can even run the first command in one machine and the other two commands in another terminal of the same machine. gst-remote can even control a VM on a separate machine, though for security reasons you should make sure that it is not accessible from outside (either block it or at least put the machine in your DMZ!).

In order to run your web apps, you can first load the Seaside packages and build a new image with them:

$ gst
st> PackageLoader fileInPackage: 'Seaside'
st> PackageLoader fileInPackage: 'Seaside-Development'
st> PackageLoader fileInPackage: 'Seaside-Examples'
st> ObjectMemory snapshot: ''

Then, this command will start Seaside on port 8080:

$ gst-remote -I --server --start=Seaside

You can then point your browser to http://localhost:8080/seaside/ and play with the configuration editor and with the Seaside examples and tests.

In order to create your first component, place this in a file:

Seaside.WAComponent subclass: MyCounter [
    | count |
    MyCounter class >> canBeRoot [ ^true ]

    initialize [
        super initialize.
        count := 0.
    states [ ^{ self } ]
    renderContentOn: html [
        html heading: count.
        html anchor callback: [ count := count + 1 ]; with: '++'.
        html space.
        html anchor callback: [ count := count - 1 ]; with: '--'.

MyCounter registerAsApplication: 'mycounter'

Then, file it in:

$ gst-remote --file

and start your browser again. You will see a new Application at http://localhost:8080/seaside/mycounter—congratulations, this is your firrst Seaside component for GNU Smalltalk!

(Please put your favorite Seaside tutorial in comments)

When I execute MyCounter example. following errors.

$ gst-remote -f
gst-remote: server unavailable

I don't understood how gst-remote recognize image?

You have to run server first like this;

$ gst-remote -I --server --start=Seaside

then at other terminal you can;

$ gst-remote -f

run this.

It works. thanks.

Has anyone seen this when running on Mac and installing from MacPorts:

netserve:~ root# /opt/local/bin/gst-remote -I /var/root/ --server --start=Seaside
gst-remote server started.
No runnable processAbort trap

Not sure what I'm doing wrong and I'm a hopeless newb.

Out of curiosity...

How do you debug ? (I come from squeak). In case of problem with the seaside app, I imagine there's no link to debug in the image...


It is there, IIRC on a stock image it will just show a backtrack on stdout. But you can load the GUI too.


I built a fresh 3.0.2 and:

sam@caveman:~/projects/smalltalk/learning/seaside$ ls -al /usr/local/bin
total 264
drwxrwsr-x 2 root staff 4096 Mar 20 00:34 .
drwxrwsr-x 12 root staff 4096 Mar 20 00:34 ..
-rwxr-xr-x 1 root staff 28455 Mar 20 00:34 gst
-rwxr-xr-x 7 root staff 29094 Mar 20 00:34 gst-blox
-rwxr-xr-x 1 root staff 1912 Mar 20 00:34 gst-config
-rwxr-xr-x 7 root staff 29094 Mar 20 00:34 gst-convert
-rwxr-xr-x 7 root staff 29094 Mar 20 00:34 gst-doc
-rwxr-xr-x 7 root staff 29094 Mar 20 00:34 gst-load
-rwxr-xr-x 7 root staff 29094 Mar 20 00:34 gst-package
-rwxr-xr-x 7 root staff 29094 Mar 20 00:34 gst-reload
-rwxr-xr-x 7 root staff 29094 Mar 20 00:34 gst-sunit

Where would I find gst-remote? Or did I miss something to ./configure and not get it built?

I was confused by the naming of 3.0a -- 3.0a is more a 3.1-alpha than anything that would be superseded by 3.0.2.


Pretty nifty! Is there a way to get into the Halo mode (turn on the dev toolbar)?

Load Seaside-Development and add WAToolConfiguration to the application or dispatcher you want to debug.

Please explain what you mean by this :

 Load Seaside-Development and add WAToolConfiguration

If possible, the relevant command-line or smalltalk commands. Thanks!

To enable halos, go to the configuration page (http://localhost:8080/seaside/config or something like that) for your application. There is an "Add configuration" dropdown list from which you can choose WAToolConfiguration. That enables halos.

Built from git-master on February 12th on OpenSUSE 11.1.

The dropdown it seems you are referring to appears to be titled 'Ancestry'.

Also, 'WAToolConfiguration' appears to now reside in 'Seaside-Development-Core' *but* 'PackageLoader fileInPackage: 'Seaside-Development-Core'' fails with 'package not found'.

When I filed '' in directly from the command line, saved a snapshot and restarted the server, the dropdown marked 'Ancestors' still has only 'WAAuthConfiguration' and 'WAFileSystemConfiguration'.

As a developer of 30 years experience, threads like this make me a little sad. You guys do so much hard work, but for lack of a little correct documentation, people give up and go away, usually because their hacking time is very limited, and they can't afford to spend what they percieve as days and weeks trying to get even the tutorial working.

The ironic part is, if I didn't have to spend my time figuring out how to get this working, I could help document. But my available time is very limited, and it still isn't working -- and if I can't get it working, I can't document *how* to get it working, now can I?

See what I mean?

Thanks for all cool stuff!

To use this tutorial one would do well to use the downloadable 'change set'. It seems that some very obvious changes would be needed to get it to work with the GNU Smalltalk seaside classes, but getting at the text of the file is a challenge. Turns out that this file is some sort of squeaky munge of text. Does anyone have suggestions for how I might convert this into a form I can edit in vim? I read about gst-convert but I would first like to comfortably read the contents if I can. Thanks!

You can use tr \\r \\n to look at the changeset. After that, you can used gst-convert as explained in the FAQ.

Good work guys! I've been waiting for this =].


User login