[Seaside-dev] Re: ZnSeasideStaticServerAdaptorDelegate

Sven Van Caekenberghe sven at stfx.eu
Thu Sep 22 07:38:13 UTC 2016


Hi Johan,

The original code was a bit of a hack, IMHO, but your solution makes way more sense, because it is more specific, so OK for me.

Sven

> On 22 Sep 2016, at 09:32, Johan Brichau <johan at inceptive.be> wrote:
> 
> Hi all, (cc: Sven)
> 
> I just started to use the ZnSeasideStaticServerAdaptorDelegate to replace our uses of Seaside-Filesystem (exposing external file directories in Seaside handlers) in the development environment.
> The Zinc solution is really better, but I noticed it is a bit too liberal about throwing away error responses coming from the Seaside backend. 
> 
> Our application (and its API, which is a separate handler) responds different errors which should really be answered to the client.
> The ZnSeasideStaticServerAdaptorDelegate tries to look for a file upon _any_ error coming from the Seaside backend and will eventually yield a 404 because it cannot find a file for the given url either.
> 
> I propose to change the code as shown below. A file should only be searched when the Seaside backend responds a 404 and if the file was not found, we just return the original error response.
> This yields the expected behaviour in our case, which I think is not specific to our application.
> 
> What do you think?
> 
> Cheers
> Johan
> 
> 
> handleRequest: znRequest
> 	"If the Seaside request processing apparatus returns an HTTP response with a 'not found' error
> 	check the filesystem for a file that matches the uri of the request, if found send the file if not send the original error."
> 
> 	| response staticResponse |
> 	response := self adaptor process: znRequest.
> 	^ (response isNotFound and: [ response isAuthenticationRequired not ])
> 			ifTrue: [ 
> 				staticResponse := self staticDelegate handleRequest: znRequest.
> 				staticResponse isNotFound ifTrue:[ response ] ifFalse:[ staticResponse ] ]
> 			ifFalse: [ response ].



More information about the seaside-dev mailing list