[Seaside] HTTP Server Structure
Stephen Pair
stephen at pairhome.net
Wed Nov 19 15:27:16 CET 2003
Sven Van Caekenberghe wrote:
> On 18 Nov 2003, at 00:20, Nevin Pratt wrote:
>
>> Sven Van Caekenberghe wrote:
>
>
>>> No, my question was, why make a subclass of WAKom instead of a
>>> module/plug/whatever directly in Comanche ?
>>
>>
>
> To answer my own question: I now have Seaside, static file serving and
> XML-RPC in one image, under the same port using this code:
>
> | ma xmlrpc seaside |
> ma := ModuleAssembly core.
> ma serverRoot: (FileDirectory on: '/Users/sven/Sites/') fullName.
> xmlrpc := XMLRPCHttpModule new.
> ma alias: '/xmlrpc' to: [ma addPlug: [:request | xmlrpc process:
> request]].
> seaside := WAKom default.
> ma alias: '/seaside' to: [ma addPlug: [:request | seaside process:
> request]].
> ma documentRoot: (FileDirectory on: '/Users/sven/Sites/') fullName.
> ma directoryIndex: 'index.html index.htm'.
> ma serveFiles.
> (HttpService startOn: 9090 named: 'httpd') plug: ma rootModule
>
> This is very elegant, I like begin to like the heavily refactored
> design that was confusing at first.
>
> Sven
Actually, it can get more elegant than that. If the XML-RPC and Seaside
modules were both implemented as subclasses of ComancheModule, you could
do something like:
| ma |
ma := ModuleAssembly core.
ma serverRoot: (FileDirectory on: '/Users/sven/Sites/') fullName.
ma alias: '/xmlrpc' to: [ma addModule: XMLRPCModule new].
ma alias: '/seaside' to: [ma addModule: SeasideModule new].
ma documentRoot: (FileDirectory on: '/Users/sven/Sites/') fullName.
ma directoryIndex: 'index.html index.htm'.
ma serveFiles.
(HttpService startOn: 9090 named: 'httpd') plug: ma rootModule
The Seaside and XML modules could also extend the ModuleAssembly class
with new methods such that you could then refine this to something like:
| ma |
ma := ModuleAssembly core.
ma serverRoot: (FileDirectory on: '/Users/sven/Sites/') fullName.
ma alias: '/xmlrpc' to: [ma enableXMLRPC].
ma alias: '/seaside' to: [ma invokeSeaside].
ma documentRoot: (FileDirectory on: '/Users/sven/Sites/') fullName.
ma directoryIndex: 'index.html index.htm'.
ma serveFiles.
(HttpService startOn: 9090 named: 'httpd') plug: ma rootModule
The #addPlug: method is intended to be used where you really need to
plug in a Block or MessageSend (i.e. you need to adapt to something that
doesn't implement the ComancheModule protocol).
- Stephen
More information about the Seaside
mailing list