[Seaside-dev] About mimeDocumentClass
Paolo Bonzini
bonzini at gnu.org
Thu Mar 6 08:19:08 UTC 2008
Why should the platform support module provide a MIME document class?
IMO a minimal implementation should be present in the form of a
WAMIMEDocument class within Seaside-Core, like it's done with URLs and
MIME types; then, platform support is free to return another class if it
is polymorphic with WAMimeDocument.
Here is my super-basic implementation:
Object subclass: #WAMimeDocument
instanceVariableNames: 'contentStream content contentType'
classVariableNames: ''
poolDictionaries: ''
category: 'Seaside-Core-HTTP'!
!WAMimeDocument class methodsFor: 'instance creation'!
contentType: mimeType content: content
^self new contentType: mimeType contentStream: nil content: content
!
contentType: mimeType contentStream: stream
^self new contentType: mimeType contentStream: stream content: nil
! !
!WAMimeDocument methodsFor: 'basic'!
asMIMEDocument
^self
!
asMIMEDocumentType: type
type toString = contentType toString ifTrue: [ ^self ].
^self class new
contentType: type contentStream: contentStream content:
content
! !
!WAMimeDocument methodsFor: 'initialization'!
contentType: mimeType contentStream: stream content: anObject
contentType := mimeType.
contentStream := stream.
content := anObject
! !
!WAMimeDocument methodsFor: 'accessing'!
contentStream
contentStream isNil ifTrue: [ ^content readStream ].
^contentStream
!
contentType
^contentType
!
content
contentStream isNil ifFalse: [ ^contentStream contents ].
^content
! !
More information about the seaside-dev
mailing list