smalltalk
/
osmo-st-all
Archived
1
0
Fork 0

Using a new approch for Object>>asResponse using #respondOn: and #displayOn: instead of #printOn: by Stefan Schmiedl

This commit is contained in:
Nicolas Petton 2009-06-22 00:32:14 +00:00
parent 97efb27d2d
commit e18b2a262c
5 changed files with 19 additions and 29 deletions

View File

@ -77,8 +77,8 @@ IliadObject subclass: Action [
^self block cull: self value
]
asResponse [
<category: 'request handling'>
^self value asResponse
respondOn: aResponse [
<category: 'converting'>
^self value displayOn: aResponse
]
]

View File

@ -286,11 +286,11 @@ the application mode:
^[:e | ]
]
asResponse [
<category: 'responding'>
respondOn: aResponse [
<category: 'converting'>
self build.
self updatePage.
^self page asResponse
self page respondOn: aResponse
]
defaultPageClass [

View File

@ -89,9 +89,9 @@ My subclasses must override the #build method, which should return an instance o
self application redirectToLocal: aString
]
asResponse [
<category: 'responding'>
^self build asResponse
respondOn: aResponse [
<category: 'converting'>
self build respondOn: aResponse
]
]

View File

@ -39,18 +39,14 @@ Object extend [
asResponse [
<category: 'converting'>
^Iliad.Response ok
nextPutAll: self printString;
yourself
| response |
response := Iliad.Response ok.
self respondOn: response.
^response
]
]
String extend [
asResponse [
respondOn: aResponse [
<category: 'converting'>
^Iliad.Response ok
nextPutAll: self;
yourself
self displayOn: aResponse
]
]

View File

@ -177,15 +177,9 @@ I know how to print myself in HTML format with the #printHtmlOn: method'>
^(AttributeNotUnderstood element: self attribute: aString) signal
]
asResponse [
<category: 'request handling'>
| str |
str := WriteStream on: ''.
self printHtmlOn: str.
children := OrderedCollection new.
^Response ok
contentType: self contentType;
nextPutAll: str contents;
yourself
respondOn: aResponse [
<category: 'converting'>
self printHtmlOn: aResponse.
aResponse contentType: self contentType
]
]