WAKom


Seaside-Platform

Comment:

I provide an adapter between Seaside and the Comanche web server. To start a new server on port 8080, evaluate

	WAKom startOn: 8080.
	
and to stop it, evaluate

	WAKom stop.
	
The state of the service (running or stopped) is automatically restored when quitting and reopening an image.

If you want to reset the password of the config application (reachable at /seaside/config) evaluate

	WADispatcherEditor initialize.

Hierarchy:

ProtoObject
Object
WAKom

Summary:

instance variables:

entryPoint

class instance variables:

port service

methods:

instance class
as yet unclassified kom 6.1 as yet unclassified service

Detail:

instance variables:

entryPoint
inferredType:
UndefinedObject

class instance variables:

port
inferredType:
UndefinedObject
service
inferredType:
UndefinedObject

instance methods:

as yet unclassified
convertRequest: aKomRequest

	| request |
	self processMultipartFields: aKomRequest.

	request _ WARequest
		method: aKomRequest method
		url: aKomRequest url unescapePercents 
		headers: aKomRequest header
		fields: (aKomRequest method = 'POST'
					ifTrue: [aKomRequest postFields]
					ifFalse: [aKomRequest getFields])
		cookies: aKomRequest cookies
		nativeRequest: aKomRequest.

	aKomRequest method = 'PUT'
		ifTrue: [request fields
					at: 'PUTData'
					put: (aKomRequest stream next: aKomRequest contentLength)].
	^ request
convertResponse: aResponse

	| komResponse |
	aResponse ifNil: [^ HttpResponse fromString: 'Request handling aborted; reload to retry'].

	komResponse _  HttpResponse new.

	aResponse cookies do:
		[:assoc | komResponse setCookieName: assoc key value: assoc valueWithExpiry path: assoc path].
		
	aResponse headers associationsDo: [:assoc | komResponse fieldAt: assoc key put: assoc value].
	(HttpResponse classPool at: #StatusCodes) associationsDo:
		[:assoc |
		assoc value key = aResponse status ifTrue: [komResponse status: assoc key]].
	komResponse contents: aResponse contents.
	komResponse contentType: aResponse contentType.

	^ komResponse
entryPoint: anEntryPoint

	entryPoint _ anEntryPoint
handleRequest: aRequest

	^ (entryPoint handlerForRequest: aRequest) handleRequest: aRequest
log: aRequest

	Transcript cr; show: aRequest url
process: komRequest

	|request response komResponse |
	self log: komRequest.
	request _ self convertRequest: komRequest.

	response _ self handleRequest: request.
	komResponse _ self convertResponse: response.

	response release.
	^ komResponse
processMultipartFields: aRequest

	aRequest multipartFormFieldsDo:
		[:chunk |
		chunk fileName isEmptyOrNil ifFalse:
			[|stream file|
			stream _ WriteStream on: String new.
			chunk saveToStream: stream.
			file _ WAFile new fileName: chunk fileName; contents: stream contents; contentType: chunk contentType.
			aRequest postFields at: chunk fieldName put: file]].

kom 6.1
processHttp

	HttpResponse current: (self process: HttpRequest current).
	^ true
processHttpRequest: aRequest

	^ self process: aRequest
validateForStack: anArray


class methods:

as yet unclassified
default

	^ self entryPoint: WADispatcher default
entryComponent: aClass path: aString

	^ self dispatcher: (aClass applicationWithPath: aString)
entryPoint: anEntryPoint

	^ self new entryPoint: anEntryPoint

service
createService

	Smalltalk at: #HttpService ifPresent:
		[:hs |
		^ (hs on: port named: 'seaside') plug: self default].
	Smalltalk at: #ComancheNetService ifPresent:
		[:cns |
		^ (cns named: 'seaside' onPort: port) module: self default]
initialize

		Smalltalk addToStartUpList: self after: AutoStart.
		Smalltalk addToShutDownList: self
pause

	service ifNotNil:
		[service unregister.
		service _ nil]
setDebugMode

	service setDebugMode.
setDeploymentMode

	service setDeploymentMode.
setVerboseMode

	service setVerboseMode.
shutdown

	self pause
startOn: aPort

	self stop.
	port _ aPort.
	service _ self createService.
	service start.
startUp

	port ifNotNil: [self startOn: port]
stop

	self pause.
	port _ nil.

^top


- made by Dandelion -