[Seaside] HTTP Server Structure

Nevin Pratt nevin at smalltalkpro.com
Mon Nov 17 17:40:50 CET 2003

Sven Van Caekenberghe wrote:

> For example, what is the right/simple way to serve some static files ? 
> There seem to be several ways of doing it, but I can't get any of them 
> to work reliably. Where can I learn more about this ?

Here is what I do:

I have a custom subclass of WAKom (which I happen to call 
ComancheInterface) for connecting Comanche to Seaside. (I use Comanche 
5.x, and Seaside 2.x -- Sorry, I've forgotten what the 'x' value is for 
both of them).

I implement a ComancheInterface>>process: method that essentially does this:

process: aRequest
    | url |
    httpRequest _ aRequest.
    url _ httpRequest url.
    (url beginsWith: '/seaside/')
        ifTrue: [^ self processSeaside: aRequest].
    self processMultipartFields: aRequest.
    ^ self siteManager process: httpRequest

Then, my #processSeaside: method is essential WAKom's process: method.

'self siteManager' just returns a normal Comanche module that is 
appropriate for the incoming URL.  The default siteManager module has a 
#process: method similar to the following:

process: aRequest
    | str docFile doc |
    doc _ self relativePath.
    (self class cgiMap
            at: doc
            ifAbsent: []) isNil
        ifFalse: [^ self
                perform: (self class cgiMap at: doc)].
    [docFile _ (FileDirectory on: self docRoot)
                oldFileNamed: doc]
        on: FileDoesNotExistException
        do: [:ex |
            self logError: ex asString.
            ^ self errorPage].
    (docFile name endsWith: 'ssp')
        ifTrue: [str _ HTMLformatter evalEmbedded: docFile contents 
with: httpRequest.
            docFile close]
        ifFalse: [str _ docFile].
    ^ str

With this approach, for any URL that does *not* have '/seaside/' in it, 
Comanche handles it.  When Comanche handles it, my default #process: 
method for Comanche allows classic cgi style processing, as well as ssp 
processing (for embedding Smalltalk code into the pages), as well as 
static file serving.  And, instead of the default, I can insert any 
Comanche module into it instead.

And, for any URL that has '/seaside/' in it, the request is passed to 

Thus, static file serving, and a bunch more, is integrated into Seaside.

In actual practice, though, I find myself never using ssp, or any 
cgi-style processing, or any other Comanche modules, or any other 
tricks.  On my bountifulbaby.com site, everything is either pure Seaside 
(with '/seaside/' in the URL), or else a jpg image served statically. 
 And most of the time I don't even serve the images statically that way, 
as I instead let Earthlink host the pictures, and my site just serves 
pure Seaside.

In fact, in hindsight, I doubt I would have bothered with all of the 
above.  I'd have probably just let my site serve Seaside, and let my 
Earthlink site serve all of the static stuff.  The static stuff (i.e., 
pictures) are the most bandwidth intensive-- let it chew up Earthlink's 
bandwidth rather than mine. :-)  Of course, I pay an extra $19.95 a 
month for that privilege, but it's worth it.


Nevin Pratt
Bountiful Baby
(801) 992-3137

More information about the Seaside mailing list