Hi everybody!
I'm working on a project using Seaside for the first time, and for various reasons it needs to output Content-Type: "text/plain" documents. So having no idea, how Seaside's internals work I started sticking in random 'self break' statements, until I found a place that the Content-Type was set. What I did so far was:
WAHtmlRoot<<contentType ^ mimeType ifNil: ['text/html'] ifNotNil: [mimeType]
WAHtmlRoot<<mimeType ^ mimeType
WAHtmlRoot<<mimeType: aString ^ mimeType := aString
This at least allows me to change what was previously a hardcoded content type, but it wasn't enough to allow access from the viewer as I couldn't find an obvious way to access the response object through the html one so:
WAHtmlDocument<<response ^response
WAHtmlDocument<<response: aResponse ^response := aResponse
WARender<<buildResponse | response document | self updateUrl: url. context actionUrl: url. response := self newResponse. response headerAt: 'Cache-Control' put: 'No-cache'. document := self session outputDocumentClass root: self buildDocRoot. document stream: response stream. * document response: response.* context document: document. root decorationChainDo: [:ea | ea renderWithContext: context]. self writeOnLoadOn: document. document close. ^ response
At this point I could now alter the response within my View class:
TestView<<renderContentOn: html html context document response contentType: 'text/plain'. html text: 'Testing 1 2 3'
Generates a page of type 'text/plain' but the page is just the javascript load preamble:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><title>Seaside</title><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><link type="text/css" href="/seaside/files/WAStandardFiles/basics.css" rel="stylesheet" /><link type="text/css" href="/seaside/files/WAStandardFiles/kalseyTabs.css" rel="stylesheet" /><link type="text/css" href="/seaside/files/WAStandardFiles/sourceStyle.css" rel="stylesheet" /><script type="text/javascript" src="/seaside/files/WAStandardFiles/externalAnchors.js"></script><script type="text/javascript" src="/seaside/files/WAStandardFiles/misc.js"></script><script type="text/javascript" src="/seaside/files/WAStandardFiles/shortcuts.js"></script><link type="text/css" href="/seaside/Test?_s=UbxOBKHRLUulbtSV" rel="stylesheet" /></head><body onkeydown="onKeyDown(event)" onload="onLoad()"><div id="frameContent">testing 1 2 3</div><div> </div><p></p><div id="toolbar"><a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&1">New Session</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&2">Configure</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&3">Toggle Halos</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&4">Spot Profiler</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&5">Memory</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&6">Profiler</a> <a href="http://localhost:3900/seaside/Test?terminate=1&_s=VkiqJeuwtxwWVIAM&_k=zekhIJre">Terminate</a> <a title="Validate XHTML" href="http://validator.w3.org/check/referer">XHTML</a> <span title="Render Time">0</span>/<span title="Callback Time">0</span> ms</div><script type="text/javascript">/*<![CDATA[*/function onLoad(){}/*]]>*/</script></body></html>
So my question is how do I override this!
I noticed that I can override the response stream in my View object, but there's a continuation which gets called which will overwrite whatever I put in the stream. Am I going about this totally the wrong way?
Dave
2007/6/2, David Goehrig dave@nexttolast.com:
Hi everybody!
I'm working on a project using Seaside for the first time, and for various reasons it needs to output Content-Type: "text/plain" documents.
Can you elaborate a bit? You are a aware that this is the wrong mime-type for an html document and if you succeed in this, it will cause the document to be not rendered at all and instead the source code to be shown. Do you need that only for the html documents? Do you need it only in the http header or also in the html head meta element.
So having no idea, how Seaside's internals work I started sticking in random 'self break' statements, until I found a place that the Content-Type was set. What I did so far was:
WAHtmlRoot<<contentType ^ mimeType ifNil: ['text/html'] ifNotNil: [mimeType]
At this point it would really help if we knew what version of Seaside you used. For the older ones I think setting the mimeType in the #initialize method of your session class should work fine. For newer ones #updateRoot: should do it.
WAHtmlRoot<<mimeType ^ mimeType
WAHtmlRoot<<mimeType: aString ^ mimeType := aString
This at least allows me to change what was previously a hardcoded content type, but it wasn't enough to allow access from the viewer as I couldn't find an obvious way to access the response object through the html one so:
WAHtmlDocument<<response ^response
WAHtmlDocument<<response: aResponse ^response := aResponse
WARender<<buildResponse | response document | self updateUrl: url. context actionUrl: url. response := self newResponse. response headerAt: 'Cache-Control' put: 'No-cache'. document := self session outputDocumentClass root: self buildDocRoot. document stream: response stream. document response: response. context document: document. root decorationChainDo: [:ea | ea renderWithContext: context]. self writeOnLoadOn: document. document close. ^ response
At this point I could now alter the response within my View class:
TestView<<renderContentOn: html html context document response contentType: 'text/plain'. html text: 'Testing 1 2 3'
Generates a page of type 'text/plain' but the page is just the javascript load preamble:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html
lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml%22%3E<head><title>Seaside</title><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><link type="text/css" href="/seaside/files/WAStandardFiles/basics.css" rel="stylesheet" /><link type="text/css" href="/seaside/files/WAStandardFiles/kalseyTabs.css" rel="stylesheet" /><link type="text/css" href="/seaside/files/WAStandardFiles/sourceStyle.css" rel="stylesheet" /><script type="text/javascript" src="/seaside/files/WAStandardFiles/externalAnchors.js"></script><script type="text/javascript" src="/seaside/files/WAStandardFiles/misc.js"></script><script type="text/javascript" src="/seaside/files/WAStandardFiles/shortcuts.js"></script><link type="text/css" href="/seaside/Test?_s=UbxOBKHRLUulbtSV" rel="stylesheet" /></head><body onkeydown="onKeyDown(event)" onload="onLoad()"><div id="frameContent">testing 1 2 3</div><div> </div><p></p><div id="toolbar"><a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&1">New Session</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&2">Configure</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&3">Toggle Halos</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&4">Spot Profiler</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&5">Memory</a> <a href="?_k=zekhIJre&_s=VkiqJeuwtxwWVIAM&6">Profiler</a> <a href="http://localhost:3900/seaside/Test?terminate=1&_s=VkiqJeuwtxwWVIAM&_k=zekhIJre">Terminate</a> <a title="Validate XHTML" href="http://validator.w3.org/check/referer">XHTML</a> <span title="Render Time">0</span>/<span title="Callback Time">0</span> ms</div><script type="text/javascript">/*<![CDATA[*/function onLoad(){}/*]]>*/</script></body></html>
That's not a javascript load preamble. That's a full html page showing 'testing 1 2 3' and the Seaside toolbar. I don't see the problem.
So my question is how do I override this!
I noticed that I can override the response stream in my View object, but there's a continuation which gets called which will overwrite whatever I put in the stream. Am I going about this totally the wrong way?
Cheers Philippe
Dave
Seaside mailing list Seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Philippe Marschall wrote:
Can you elaborate a bit?
Sure I need 'text/plain' because there's a flash application that is importing a JSON document, that I'd like to generate with Seaside in order to maintain the session state, etc. I realize that I can subclass WASession and attack the problem from there and create a whole new set of Seaside-Document classes for this. But was hoping not to have to rewrite half of Seaside in the process.
That's not a javascript load preamble. That's a full html page showing 'testing 1 2 3' and the Seaside toolbar. I don't see the problem.
I don't want it to render anything but the 'testing 1 2 3', I tried to override with callbacks, but I can't seem to get one registered that does the job.
Dave
2007/6/2, David Goehrig dave@nexttolast.com:
Philippe Marschall wrote:
Can you elaborate a bit?
Sure I need 'text/plain' because there's a flash application that is importing a JSON document, that I'd like to generate with Seaside in order to maintain the session state, etc. I realize that I can subclass WASession and attack the problem from there and create a whole new set of Seaside-Document classes for this. But was hoping not to have to rewrite half of Seaside in the process.
That's not a javascript load preamble. That's a full html page showing 'testing 1 2 3' and the Seaside toolbar. I don't see the problem.
I don't want it to render anything but the 'testing 1 2 3', I tried to override with callbacks, but I can't seem to get one registered that does the job.
Do you just want to return the string 'testing 1 2 3' as 'text/plain' or a whole html document around it. The former is simple:
self session returnResponse: (WAResponse document: 'testing 1 2 3' mimeType: 'text/plain')
Cheers Philippe
Dave _______________________________________________ Seaside mailing list Seaside@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
What would be the easiest way to set session timeout per session?
-Carl Gundel http://www.runbasic.com
MyRootComponent>>initialRequest: aRequest super initialRequest: aRequest. self session timeoutSeconds: 360.
-Boris
I don't want it to render anything but the 'testing 1 2 3', I tried to override with callbacks, but I can't seem to get one registered that does the job.
self session returnResponse: (WAResponse new contentType: 'text/plain'; nextPutAll: 'testing 1 2 3'; yourself)
The scriptaculous package is doing similar things to communicate with JavaScript.
Lukas
seaside@lists.squeakfoundation.org