[Seaside] Seaside text/plain output problems

Philippe Marschall philippe.marschall at gmail.com
Sat Jun 2 07:52:49 UTC 2007


2007/6/2, David Goehrig <dave at 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"><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>&nbsp;</div><p></p><div id="toolbar"><a
> href="?_k=zekhIJre&amp;_s=VkiqJeuwtxwWVIAM&amp;1">New
> Session</a>&nbsp;<a
> href="?_k=zekhIJre&amp;_s=VkiqJeuwtxwWVIAM&amp;2">Configure</a>&nbsp;<a
> href="?_k=zekhIJre&amp;_s=VkiqJeuwtxwWVIAM&amp;3">Toggle
> Halos</a>&nbsp;<a
> href="?_k=zekhIJre&amp;_s=VkiqJeuwtxwWVIAM&amp;4">Spot
> Profiler</a>&nbsp;<a
> href="?_k=zekhIJre&amp;_s=VkiqJeuwtxwWVIAM&amp;5">Memory</a>&nbsp;<a
> href="?_k=zekhIJre&amp;_s=VkiqJeuwtxwWVIAM&amp;6">Profiler</a>&nbsp;<a
> href="http://localhost:3900/seaside/Test?terminate=1&amp;_s=VkiqJeuwtxwWVIAM&amp;_k=zekhIJre">Terminate</a>&nbsp;<a
> title="Validate XHTML"
> href="http://validator.w3.org/check/referer">XHTML</a>&nbsp;<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 at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>


More information about the Seaside mailing list